Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78124 > unrolled thread

SOAPpy: Expected to find node type 'Element' with name 'CountriesFetchingRequest'; Found node type 'Element' with name 'FetchCountries'

Started byvek.m1234@gmail.com
First post2014-09-21 19:31 -0700
Last post2014-09-23 12:47 -0700
Articles 4 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  SOAPpy: Expected to find node type 'Element' with name 'CountriesFetchingRequest'; Found node type 'Element' with name 'FetchCountries' vek.m1234@gmail.com - 2014-09-21 19:31 -0700
    Re: SOAPpy: Expected to find node type 'Element' with name 'CountriesFetchingRequest'; Found node type 'Element' with name 'FetchCountries' dieter <dieter@handshake.de> - 2014-09-22 08:53 +0200
      Re: SOAPpy: Expected to find node type 'Element' with name 'CountriesFetchingRequest'; Found node type 'Element' with name 'FetchCountries' Veek M <vek.m1234@gmail.com> - 2014-09-24 09:18 +0630
    Re: SOAPpy: Expected to find node type 'Element' with name 'CountriesFetchingRequest'; Found node type 'Element' with name 'FetchCountries' ldanielburr@gmail.com - 2014-09-23 12:47 -0700

#78124 — SOAPpy: Expected to find node type 'Element' with name 'CountriesFetchingRequest'; Found node type 'Element' with name 'FetchCountries'

Fromvek.m1234@gmail.com
Date2014-09-21 19:31 -0700
SubjectSOAPpy: Expected to find node type 'Element' with name 'CountriesFetchingRequest'; Found node type 'Element' with name 'FetchCountries'
Message-ID<257bc927-4ada-4020-8b9c-7781d0802bbc@googlegroups.com>
I'm messing with SOAP, trying to write a small library to handle stuff I buy from Aramex (shipper). I'm learning XML/SOAP and I'm familiar with RPC from C (Stevens) but no other relevant experience. If this is incredibly dumb just ignore it since I'll probably figure it out eventually.

I'm trying to get a list of countries by calling the CoutriesFetchingRequest method - this is documented here:
http://www.aramex.com/developers/aramex-apis/47442/Location-Services-API
http://www.aramex.com/content/uploads/109/232/46790/aramex-location-api-manual.pdf

It takes as its arguments a 'ClientInfo' data-structure and 'Code' which is a string.

There is also a 'FetchCountries' method with an 'input' and 'output' something.
However python was more clear, print server.show_methods():

Method Name: FetchCountries 
   In #0: parameters  ((u'http://ws.aramex.net/ShippingAPI/v1/', u'CountriesFetchingRequest'))
<SNIP>

The trouble is I don't understand how to call 'CoutriesFetchingRequest' or pass it to FetchCountries. Could someone clarify?


The WSDL for Aramex has this:
http://www.aramex.com/content/uploads/109/232/46790/location-api-wsdl.zip
    <wsdl:operation name="FetchCountries">
      <wsdl:input wsaw:Action="http://ws.aramex.net/ShippingAPI/v1/Service_1_0/FetchCountries" name="CountriesFetchingRequest" message="tns:CountriesFetchingRequest" />
      <wsdl:output wsaw:Action="http://ws.aramex.net/ShippingAPI/v1/Service_1_0/FetchCountriesResponse" name="CountriesFetchingResponse" message="tns:CountriesFetchingResponse" />
    </wsdl:operation>


      <wsdl:input name="CountriesFetchingRequest">
        <soap:body use="literal" />
      </wsdl:input>

My python code:
#!/usr/bin/python
import xml, fpconst, logging
from SOAPpy import WSDL
from suds.client import Client

logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)

foo = { 'AccountCountryCode' : 'JO', 'AccountEntity' : 'AMM', 'AccountNumber' : '20016', 'AccountPin' : '331421', 'UserName' : 'testingxxx@aramex.com', 'Password' : 'R123456789$r', 'Version' : 'v1.0', 'Source' : '', 'Transaction' :  { 'Reference1' : '001', 'Reference2' : '002', 'Reference3' : '003', 'Reference4' : '004', 'Reference5' : '005' } }

wsdl_file = '/home/veek/location-api-wsdl/Location-API-WSDL.wsdl'

server = WSDL.Proxy(wsdl_file)
print server.methods.keys()
print dir(server)
print server.show_methods()
callInfo = server.methods['FetchCountries']
print type(callInfo)
print dir(callInfo)

for arg in callInfo.inparams:
    print arg.name.ljust(15), arg.type
server.namespace = 'http://ws.aramex.net/ShippingAPI/v1/'
x = server.FetchCountries.CountriesFetchingRequest(foo)

The output i get is:
[u'FetchCountries', u'FetchCountry', u'ValidateAddress', u'FetchCities', u'FetchOffices']
['__doc__', '__getattr__', '__init__', '__module__', '__str__', 'methods', 'show_methods', 'soapproxy', 'wsdl']
Method Name: FetchCountries 

   In #0: parameters  ((u'http://ws.aramex.net/ShippingAPI/v1/', u'CountriesFetchingRequest'))

   Out #0: parameters  ((u'http://ws.aramex.net/ShippingAPI/v1/', u'CountriesFetchingResponse'))

<SNIP>

None
<type 'instance'>
['__doc__', '__init__', '__module__', 'addInHeaderInfo', 'addInParameter', 'addOutHeaderInfo', 'addOutParameter', 'documentation', 'encodingStyle', 'getInHeaders', 'getInParameters', 'getOutHeaders', 'getOutParameters', 'getReturnParameter', 'inheaders', 'inparams', 'location', 'methodName', 'namespace', 'outheaders', 'outparams', 'retval', 'setReturnParameter', 'soapAction', 'style', 'transport', 'use']
parameters      (u'http://ws.aramex.net/ShippingAPI/v1/', u'CountriesFetchingRequest')

<SNIP>

SOAPpy.Types.faultType: <Fault a:InternalServiceFault: Error in deserializing body of request message for operation 'FetchCountries'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'CountriesFetchingRequest' and namespace 'http://ws.aramex.net/ShippingAPI/v1/'. Found node type 'Element' with name 'FetchCountries.CountriesFetchingRequest' and namespace '': 
<SNIP>

[toc] | [next] | [standalone]


#78126

Fromdieter <dieter@handshake.de>
Date2014-09-22 08:53 +0200
Message-ID<mailman.14186.1411368848.18130.python-list@python.org>
In reply to#78124
vek.m1234@gmail.com writes:

> I'm messing with SOAP, trying to write a small library to handle stuff I buy from Aramex (shipper). I'm learning XML/SOAP and I'm familiar with RPC from C (Stevens) but no other relevant experience. If this is incredibly dumb just ignore it since I'll probably figure it out eventually.
> ...
> The trouble is I don't understand how to call 'CoutriesFetchingRequest' or pass it to FetchCountries. Could someone clarify?

I have no experience with "SOAPpy", but with "suds" (another Python
SAOP client). A "suds" client exposes two attributes "factory"
and "service". You use the "factory" to create Python objects
for types defined by the WSDL; you then set  their attributes with standard
Python means (maybe involving other "factory" calls). Finally
you call the methods via the "service" attribute passing arguments
of the appropiate type in the normal Python way.

I suppose, it is similar with "SOAPpy". Looking at its documentation
and/or its examples may provide you with the necessary details.
Otherwise, you could also use "suds".

[toc] | [prev] | [next] | [standalone]


#78264

FromVeek M <vek.m1234@gmail.com>
Date2014-09-24 09:18 +0630
Message-ID<lvtetu$i0u$1@dont-email.me>
In reply to#78126
dieter wrote:
> I have no experience with "SOAPpy", but with "suds" (another Python
> SAOP client). A "suds" client exposes two attributes "factory"
*miaows happily*

[toc] | [prev] | [next] | [standalone]


#78244

Fromldanielburr@gmail.com
Date2014-09-23 12:47 -0700
Message-ID<1db5ea76-840e-475f-a8b4-1e1539f8d709@googlegroups.com>
In reply to#78124
On Sunday, September 21, 2014 9:31:46 PM UTC-5, vek....@gmail.com wrote:
> I'm messing with SOAP, trying to write a small library to handle stuff I buy from Aramex (shipper). I'm learning XML/SOAP and I'm familiar with RPC from C (Stevens) but no other relevant experience. If this is incredibly dumb just ignore it since I'll probably figure it out eventually.
> 
> 
> 
> I'm trying to get a list of countries by calling the CoutriesFetchingRequest method - this is documented here:
> 
> http://www.aramex.com/developers/aramex-apis/47442/Location-Services-API
> 
> http://www.aramex.com/content/uploads/109/232/46790/aramex-location-api-manual.pdf
> 
> 
> 
> It takes as its arguments a 'ClientInfo' data-structure and 'Code' which is a string.
> 
> 
> 
> There is also a 'FetchCountries' method with an 'input' and 'output' something.
> 
> However python was more clear, print server.show_methods():
> 
> 
> 
> Method Name: FetchCountries 
> 
>    In #0: parameters  ((u'http://ws.aramex.net/ShippingAPI/v1/', u'CountriesFetchingRequest'))
> 
> <SNIP>
> 
> 
> 
> The trouble is I don't understand how to call 'CoutriesFetchingRequest' or pass it to FetchCountries. Could someone clarify?
> 
> 
> 
> 
> 
> The WSDL for Aramex has this:
> 
> http://www.aramex.com/content/uploads/109/232/46790/location-api-wsdl.zip
> 
>     <wsdl:operation name="FetchCountries">
> 
>       <wsdl:input wsaw:Action="http://ws.aramex.net/ShippingAPI/v1/Service_1_0/FetchCountries" name="CountriesFetchingRequest" message="tns:CountriesFetchingRequest" />
> 
>       <wsdl:output wsaw:Action="http://ws.aramex.net/ShippingAPI/v1/Service_1_0/FetchCountriesResponse" name="CountriesFetchingResponse" message="tns:CountriesFetchingResponse" />
> 
>     </wsdl:operation>
> 
> 
> 
> 
> 
>       <wsdl:input name="CountriesFetchingRequest">
> 
>         <soap:body use="literal" />
> 
>       </wsdl:input>
> 
> 
> 
> My python code:
> 
> #!/usr/bin/python
> 
> import xml, fpconst, logging
> 
> from SOAPpy import WSDL
> 
> from suds.client import Client
> 
> 
> 
> logging.basicConfig(level=logging.INFO)
> 
> logging.getLogger('suds.client').setLevel(logging.DEBUG)
> 
> 
> 
> foo = { 'AccountCountryCode' : 'JO', 'AccountEntity' : 'AMM', 'AccountNumber' : '20016', 'AccountPin' : '331421', 'UserName' : 'testingxxx@aramex.com', 'Password' : 'R123456789$r', 'Version' : 'v1.0', 'Source' : '', 'Transaction' :  { 'Reference1' : '001', 'Reference2' : '002', 'Reference3' : '003', 'Reference4' : '004', 'Reference5' : '005' } }
> 
> 
> 
> wsdl_file = '/home/veek/location-api-wsdl/Location-API-WSDL.wsdl'
> 
> 
> 
> server = WSDL.Proxy(wsdl_file)
> 
> print server.methods.keys()
> 
> print dir(server)
> 
> print server.show_methods()
> 
> callInfo = server.methods['FetchCountries']
> 
> print type(callInfo)
> 
> print dir(callInfo)
> 
> 
> 
> for arg in callInfo.inparams:
> 
>     print arg.name.ljust(15), arg.type
> 
> server.namespace = 'http://ws.aramex.net/ShippingAPI/v1/'
> 
> x = server.FetchCountries.CountriesFetchingRequest(foo)
> 
> 
> 
> The output i get is:
> 
> [u'FetchCountries', u'FetchCountry', u'ValidateAddress', u'FetchCities', u'FetchOffices']
> 
> ['__doc__', '__getattr__', '__init__', '__module__', '__str__', 'methods', 'show_methods', 'soapproxy', 'wsdl']
> 
> Method Name: FetchCountries 
> 
> 
> 
>    In #0: parameters  ((u'http://ws.aramex.net/ShippingAPI/v1/', u'CountriesFetchingRequest'))
> 
> 
> 
>    Out #0: parameters  ((u'http://ws.aramex.net/ShippingAPI/v1/', u'CountriesFetchingResponse'))
> 
> 
> 
> <SNIP>
> 
> 
> 
> None
> 
> <type 'instance'>
> 
> ['__doc__', '__init__', '__module__', 'addInHeaderInfo', 'addInParameter', 'addOutHeaderInfo', 'addOutParameter', 'documentation', 'encodingStyle', 'getInHeaders', 'getInParameters', 'getOutHeaders', 'getOutParameters', 'getReturnParameter', 'inheaders', 'inparams', 'location', 'methodName', 'namespace', 'outheaders', 'outparams', 'retval', 'setReturnParameter', 'soapAction', 'style', 'transport', 'use']
> 
> parameters      (u'http://ws.aramex.net/ShippingAPI/v1/', u'CountriesFetchingRequest')
> 
> 
> 
> <SNIP>
> 
> 
> 
> SOAPpy.Types.faultType: <Fault a:InternalServiceFault: Error in deserializing body of request message for operation 'FetchCountries'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'CountriesFetchingRequest' and namespace 'http://ws.aramex.net/ShippingAPI/v1/'. Found node type 'Element' with name 'FetchCountries.CountriesFetchingRequest' and namespace '': 
> 
> <SNIP>

Give pysimplesoap a try; you can point it at the wsdl endpoint, and it will provide you a client that lets you call methods in about as obvious a manner as you can reasonably hope for, given the mess that is SOAP.

See https://code.google.com/p/pysimplesoap/wiki/SoapClient for some examples.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web