Harald Schneider
Harald Schneider

Reputation: 41

PySimpleSoap: How to pass a complexType as a function parameter

I have a wsdl file with a function called ImportTransportDocument. The function takes 3 parameters, a session ID, options and a document.

Calling the function without options works well, but when I try to submit the options parameter it throws an exception.

The options parameter is a complex type.

In which format do I have to submit the complex type? I tried a plain string and a dictionary without success.

The wsdl contains the following information:

   <element name="ImportTransportDocument">
   <complexType>
    <sequence>
     <element name="sessionid" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
     <element name="options" type="eakte2:transportoption" minOccurs="0" maxOccurs="1" nillable="true"/>
     <element name="base64data" type="xsd:base64Binary" minOccurs="0" maxOccurs="1" nillable="true"/>
    </sequence>
   </complexType>
  </element>
    ....
<complexType name="transportoption">
   <sequence>
     <element name="distribution" type="xsd:string" minOccurs="1" maxOccurs="1"/>
     <element name="dekadenmeldung" type="xsd:string" minOccurs="1" maxOccurs="1"/>
     <element name="storno" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
   </sequence>
  </complexType>

Calling the .help() method shows

ImportTransportDocument(sessionid=, options={u'distribution': , u'dekadenmeldung': , u'storno': }, base64data=) -> {u'message': , u'message2': }:

Calling the function with

    opt = {'distribution': '', 'dekadenmeldung': 'true', 'storno': 'true'}
    self.result = self.client.ImportTransportDocument(self.session_id, opt, base64.encodestring(doc))

gives the following Exception:

 File "/Library/Python/2.7/site-packages/pysimplesoap/client.py", line 181, in <lambda>
return lambda *args, **kwargs: self.wsdl_call(attr, *args, **kwargs)
 File "/Library/Python/2.7/site-packages/pysimplesoap/client.py", line 346, in wsdl_call
return self.wsdl_call_with_args(method, args, kwargs)
 File "/Library/Python/2.7/site-packages/pysimplesoap/client.py", line 367, in wsdl_call_with_args
method, params = self.wsdl_call_get_params(method, input, args, kwargs)
 File "/Library/Python/2.7/site-packages/pysimplesoap/client.py", line 390, in wsdl_call_get_params
raise KeyError('Unhandled key %s. use client.help(method)' % key)
KeyError: u'Unhandled key options. use client.help(method)'

Any hints?

Thank you very much, Harald

Upvotes: 1

Views: 1065

Answers (1)

Harald Schneider
Harald Schneider

Reputation: 41

I found the solution myself. If a dictionary is passed as a parameter, PySimpleSOAP expects named parameters:

self.result = self.client.ImportTransportDocument(sessionid=self.session_id, options=opt, base64data=base64.encodestring(doc))

Cheers, Harald

Upvotes: 2

Related Questions