无法创建suds未列出的数组类型的实例

时间:2011-11-09 12:50:09

标签: python xml soap wsdl suds

我正在建立一个客户端来访问一个wsdl并打印响应...在网页上打印响应...现在我被困在初始代码本身....我相信泡沫正在生成wsdl的错误的客户端方法签名给...以下是我的代码和我得到的错误:

print client

Suds ( https://fedorahosted.org/suds/ )  version: 0.4 GA  build: R699-20100913

Service ( IWS_GeocodeService_GB ) tns="http://www.g1.com/"
   Prefixes (1)
      ns0 = "http://www.g1.com/services/IWS_GeocodeService_GB"
   Ports (1):
      (IWS_GeocodeService_GBPort)
         Methods (1):
            IWS_GeocodeService_GB(ns0:context context, ns0:options options, ns0:rows rows, )
         Types (7):
            ns0:IWS_GeocodeService_GBRequest
            ns0:IWS_GeocodeService_GBResponse
            ns0:context
            ns0:options
            ns0:requestRow
            ns0:responseRow
            ns0:user_field


>>> print context1
(context){
   account.id = "spectrumd3v"
   account.password = "spectrumd3v"
 }
>>> rows = client.factory.create('ns0:rows')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/suds-0.4-py2.7.egg/suds/client.py", line 234, in create
    raise TypeNotFound(name)
suds.TypeNotFound: Type not found: 'ns0:rows'

我不确定它的发现nso:排在第一位。因为类型是WSDL def中的responseRow对象,但是它期望一个行对象......所以我无法发送msg请求!我需要在requestRow对象中发送详细信息。救命!我是新来的......

编辑:我尝试发送一个Request对象而不是行...但是没有用,我得到了以下错误

>>> resp = client.service.IWS_GeocodeService_GB(context,options,Request)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/suds-0.4-py2.7.egg/suds/client.py", line 542, in __call__
return client.invoke(args, kwargs)
File "/usr/local/lib/python2.7/dist-packages/suds-0.4-py2.7.egg/suds/client.py", line 602, in invoke
result = self.send(soapenv)
File "/usr/local/lib/python2.7/dist-packages/suds-0.4-py2.7.egg/suds/client.py", line 649, in send
result = self.failed(binding, e)
File "/usr/local/lib/python2.7/dist-packages/suds-0.4-py2.7.egg/suds/client.py", line 702, in failed
r, p = binding.get_fault(reply)
File "/usr/local/lib/python2.7/dist-packages/suds-0.4-py2.7.egg/suds/bindings/binding.py", line 265, in get_fault
raise WebFault(p, faultroot)
suds.WebFault: Server raised fault: 'Unmarshalling Error: unexpected element   (uri:"http://www.g1.com/services/IWS_GeocodeService_GB", local:"context"). Expected elements are <{http://www.g1.com/services/IWS_GeocodeService_GB}row> '

我也为此附加了xml

<wsdl:definitions name="IWS_GeocodeService_GB" targetNamespace="http://www.g1.com/">
  <wsdl:types>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://www.g1.com/services/IWS_GeocodeService_GB">
      <xs:element name="requestRow" type="tns:requestRow"/>
      <xs:element name="responseRow" type="tns:responseRow"/>
      <xs:complexType name="IWS_GeocodeService_GBRequest">
         <xs:sequence>
          <xs:element form="qualified" name="context" type="tns:context"/>
          <xs:element form="qualified" minOccurs="0" name="options" type="tns:options"/>           
          <xs:element form="qualified" name="rows">
             <xs:complexType>
              <xs:sequence>
                <xs:element form="qualified" maxOccurs="unbounded" name="row" type="tns:requestRow"/>
              </xs:sequence>
             </xs:complexType>
          </xs:element>
         </xs:sequence>
      </xs:complexType>
      <xs:complexType name="context">
         <xs:sequence>
            <xs:element form="qualified" name="account.id" type="xs:string"/>                      
            <xs:element form="qualified" minOccurs="0" name="account.password" type="xs:string"/>
         </xs:sequence>
      </xs:complexType>
      <xs:complexType name="options">
         <xs:sequence/>
      </xs:complexType>
      <xs:complexType name="requestRow">
         <xs:all>
            <xs:element form="qualified" minOccurs="0" name="AddressLine1" type="xs:string"/>
            <xs:element form="qualified" minOccurs="0" name="AddressLine2" type="xs:string"/>
            <xs:element form="qualified" minOccurs="0" name="City" type="xs:string"/>                
            <xs:element form="qualified" minOccurs="0" name="PostalCode" type="xs:string"/>
            <xs:element form="qualified" minOccurs="0" name="Country" type="xs:string"/>             
            <xs:element form="qualified" minOccurs="0" name="user_fields"><xs:complexType>

1 个答案:

答案 0 :(得分:0)

它解决了!理想情况下,这里的行只是一个python列表..我需要做的是在requestRow类型中添加一个行对象,它解决了我的问题...!