Невозможно создать экземпляр типа массива, который не указан в suds - PullRequest
0 голосов
/ 09 ноября 2011

я заставляю клиента обращаться к wsdl и распечатывать ответ .. позже при печати ответа на веб-странице ... однако сейчас я застрял в самом исходном коде .... я считаю, что suds генерируетнеправильная сигнатура методов клиента для 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: строки в первую очередь.Поскольку тип является объектом responseRow в определении WSDL, но он ожидает объект строки ... поэтому я не могу отправить запрос msg!Мне нужно отправить в деталях в объекте requestRow.Помогите!Я новичок в этом ...

РЕДАКТИРОВАТЬ: я попытался отправить объект запроса вместо строк ... это не сработало, и я получил следующую ошибку

>>> 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 голосов
/ 17 сентября 2013

это решено! В идеале строки здесь были просто списком Python. Все, что мне нужно было сделать, это добавить в них объект строки типа requestRow, который решил мою проблему ...!

...