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

vek.m1234 at vek.m1234 at
Mon Sep 22 04:31:28 CEST 2014

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:

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'', u'CountriesFetchingRequest'))

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:
    <wsdl:operation name="FetchCountries">
      <wsdl:input wsaw:Action="" name="CountriesFetchingRequest" message="tns:CountriesFetchingRequest" />
      <wsdl:output wsaw:Action="" name="CountriesFetchingResponse" message="tns:CountriesFetchingResponse" />

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

My python code:
import xml, fpconst, logging
from SOAPpy import WSDL
from suds.client import Client


foo = { 'AccountCountryCode' : 'JO', 'AccountEntity' : 'AMM', 'AccountNumber' : '20016', 'AccountPin' : '331421', 'UserName' : 'testingxxx at', '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.type
server.namespace = ''
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'', u'CountriesFetchingRequest'))

   Out #0: parameters  ((u'', u'CountriesFetchingResponse'))


<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'', u'CountriesFetchingRequest')


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 ''. Found node type 'Element' with name 'FetchCountries.CountriesFetchingRequest' and namespace '': 

More information about the Python-list mailing list