admin管理员组文章数量:1122846
I am trying to make a SOAP function on my spyne server that follows this structure.
<soap-env:Envelope xmlns:soap-env="/">
<soap-env:Body>
<test_function xmlns:ns0="Test">
<resource>
<item>
<material>gold</material>
</item>
<item>
<material>silver</material>
</item>
</resource>
</test_function>
</soap-env:Body>
</soap-env:Envelope>
Code that is closest to work is this
class Material(ComplexModel):
material = Unicode
class Resource(Array): # Changing to ComplexModel doesn't affect
item = Material
class Soap(ServiceBase):
@rpc(Resource)
def test_function(ctx, resource):
print(resource)
return "Yes"
app = Application(
[Soap],
tns='Test',
in_protocol=Soap11(),
out_protocol=Soap11()
)
application = WsgiApplication(app)
I make requests with zeep and code of client looks like this
params = {
"resource": [
{"item": {"material": "gold"}},
{"item": {"material": "silver"}}
]
}
...
with zeep_client as client:
msg = client.create_message(
client.service, 'test_function', **params)
But my request have only one <item>
, second one is missing.
I tried to play Array
in different places but they either makes code not working (unexpected arguments errors) or doesn't change anything.
Decorating function with @rpc(Array(Resource))
leads to
`TypeError: {Test}ResourceArray() got an unexpected keyword argument 'item'. Signature: `Resource: {Test}Resource[]`
本文标签: pythonSpyne define a function that accepts array of complex typesStack Overflow
版权声明:本文标题:python - Spyne define a function that accepts array of complex types - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736309235a1933945.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论