使用ZSI的Python Web服务客户端;无类结构没有';“得不到字典”;
我正试图用Python为一个简单的Web服务使用ZSI编写一个示例客户机。Web服务WSDL如下所示:使用ZSI的Python Web服务客户端;无类结构没有';“得不到字典”;,python,wsdl,zsi,Python,Wsdl,Zsi,我正试图用Python为一个简单的Web服务使用ZSI编写一个示例客户机。Web服务WSDL如下所示: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/test/" xmlns:wsdl="http://schem
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/test/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="test" targetNamespace="http://www.example.org/test/">
<wsdl:message name="NewOperationRequest">
<wsdl:part name="NewOperationRequest" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="NewOperationResponse">
<wsdl:part name="NewOperationResponse" type="xsd:string"/>
</wsdl:message>
<wsdl:portType name="test">
<wsdl:operation name="NewOperation">
<wsdl:input message="tns:NewOperationRequest"/>
<wsdl:output message="tns:NewOperationResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="testSOAP" type="tns:test">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="NewOperation">
<soap:operation soapAction="http://www.example.org/test/NewOperation"/>
<wsdl:input>
<soap:body namespace="http://www.example.org/test/" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body namespace="http://www.example.org/test/" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="test">
<wsdl:port binding="tns:testSOAP" name="testSOAP">
<soap:address location="http://localhost/test"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我收到:
(...)
/var/lib/python-support/python2.5/ZSI/TCcompound.pyc in cb(self, elt, sw, pyobj, name, **kw)
345 f = lambda attr: pyobj.get(attr)
346 if TypeCode.typechecks and type(d) != types.DictType:
--> 347 raise TypeError("Classless struct didn't get dictionary")
348
349 indx, lenofwhat = 0, len(self.ofwhat)
TypeError: Classless struct didn't get dictionary
我在谷歌上搜索了这个错误,发现了两篇描述类似问题的帖子,但都没有答案。你知道这里错了吗?WSDL中是否有错误,代码中是否有遗漏,或者ZSI中是否存在错误
提前感谢您的帮助:-)最后,我找到了解决方案 我应该这样跑:
from ZSI.ServiceProxy import ServiceProxy
service = ServiceProxy('test.wsdl')
service.NewOperation(NewOperationRequest='test')
问题的原因是缺少参数的名称(原文如此!)-愚蠢的错误;-)
from ZSI.ServiceProxy import ServiceProxy
service = ServiceProxy('test.wsdl')
service.NewOperation(NewOperationRequest='test')