【发布时间】:2019-08-23 13:13:44
【问题描述】:
我的任务是为我们的一个合作伙伴创建一个 SOAP 服务。合作伙伴向我提供了一个 WSDL 作为规范,我应该在我们这边实施。我已经取得了相当大的进步,但现在我碰壁了。
我怎样才能实现这个(<ns:Criteria id="?"> 行是问题)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://...">
<soapenv:Header/>
<soapenv:Body>
<ns:SearchRequest>
<!--1 or more repetitions:-->
<ns:Criteria id="?">
<!--Optional:-->
<ns:LocationIds>?</ns:LocationIds>
<ns:Type>?</ns:Type>
</ns:Criteria>
<ns:Channel>?</ns:Channel>
<!--You may enter ANY elements at this point-->
</ns:SearchRequest>
</soapenv:Body>
</soapenv:Envelope>
我提供服务的 Python 代码目前如下所示:
class CriteriaModel(ComplexModel):
id = String
LocationIds = String
Type = String
class SomeService(Service):
@rpc(
Array(CriteriaModel, wrapped=False),
_returns=Container,
_in_message_name='SearchRequest',
_out_message_name='SearchResponse'
)
def Search(ctx, criterias):
# pass
# TODO: implement the logic
但通过这种方法,我得到了这个结果:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ava="http://..." xmlns:book="...">
<soapenv:Header/>
<soapenv:Body>
<ava:SearchRequest>
<!--Zero or more repetitions:-->
<ava:Criteria>
<!--Optional:-->
<book:id>?</book:id>
<book:LocationIds>?</book:LocationIds>
<book:Type>?</book:Type>
</ava:Criteria>
</ava:SearchRequest>
</soapenv:Body>
</soapenv:Envelope>
这是我必须在这里实现的自定义模型吗?
非常感谢您!
【问题讨论】:
标签: python-3.x soap spyne