Using Python with a SOAP client like Suds or Zeep, if I have an API with params defined as ref or out, how do I define them and read them.
e.g. a c# method defined so:
// this is c# code...
bool MyApi(
string regularParam1,
int regularParam2,
ref string refParam3, // set by caller, changed by service,
// used as part of the result
out string outParam4) // marked as 'out', caller not to set any value,
// changed by service and used as part of the result
The soap would look so:
<soap:Body>
<MyApi xmlns="http://mywebservice.myapi.com/">
<regularParam1>string</regularParam1>
<regularParam2>int</regularParam2>
<refParam3>string</refParam3>
<outParam4>string</outParam4>
<soap:Body>
<MyApiResponse xmlns="http://mywebservice.myapi.com/">
<MyApiResult>bool<MyApiResult>
<refParam3>string</refParam3>
<outParam4>string</outParam4>
I THINK (but not sure) that both the ref param and out param expect an object that will receive the result. The out
content should be "empty" and the ref
object's content can have a value. I have no idea how this works internally.
I went through the list of Python SOAP frameworks in Samat Jain's excellent answer on a different SO question but found no discussion on the topic in any of the listed frameworks.
The problem is that there are no ref
or out
params in python.
Instead, python function calls can return multiple values, and single argurments can contain multiple values (i.e. a tuple). But what do I do when that's how it's defined in the service, and in the SOAP?
a. How do I define these params in the calling client? Do I have to do anything special, or just create regular parameters?
b. How do I get the resulting extra fields automatically (after defining them)? Or must I read the resulting SOAP xml and parse it myself?
Note: These out
and ref
parameters are part of the result, but are NOT part of the return-value
which in the example above is a simple boolean.
c. If this cannot be done in Zeep or SUDS is there some other framework where it can be accomplished?
There is a similar unanswered SO question (which I edited for clarity), but it is specific to a Zeep error that possibly is caused by ref params not defined correctly.