使用ZSI Python中的Web服务客户端 - “无类别结构并没有得到大辞典”

StackOverflow https://stackoverflow.com/questions/1496910

  •  19-09-2019
  •  | 
  •  

我想写使用ZSI一个简单的Web Service Python中的示例客户端。 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://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>

每次运行以下代码:

from ZSI.ServiceProxy import ServiceProxy
service = ServiceProxy('test.wsdl')
service.NewOperation('test')

我接收:

(...)
/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的错误,我怀念的东西在代码或有一个bug在ZSI?

感谢您提前为您有所帮助: - )

有帮助吗?

解决方案

最后,我已经找到了解决方案。

我应该运行是这样的:

from ZSI.ServiceProxy import ServiceProxy
service = ServiceProxy('test.wsdl')
service.NewOperation(NewOperationRequest='test')

该问题的原因是,该参数的名称缺失(原文如此!) - 傻误差; - )

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top