The second day I fight with a seemingly trivial task related to sending a soap request through the suds library under python.
You need to send a request with two parameters.
On the python side, this is done like this:
client.service.exportSomething(id, tstamp) If both parameters are present, then everything works fine, generated and sent this xml like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://наш_сервер"> <soapenv:Header/> <soapenv:Body> <ns:exportSomething> <ns:some_id>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</ns:some_id> <ns:tstamp>2000-01-01 00:00:00</ns:tstamp> </ns:exportSomething> </soapenv:Body> </soapenv:Envelope> The problem is that both parameters must be optional. I tried to put an empty string instead, None , suds.null (). In this case, the library generates a query, where the parameter tags are empty. For example, if I try to substitute an empty value instead of tstamp, I get this xml:
... <ns:exportSomething> <ns:some_id>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</ns:some_id> <ns:tstamp/> </ns:exportSomething> ... And instead of answering, I get an error.
Googled what needs to be written in the xml of the request in the header tag: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" and then you can indicate the absence of a value like this:
<ns:tstamp xsi:nil="true" /> If I send such an xml request manually (for example, through the SoapUI program), then I get exactly the answer that I expect.
But how can I send such a request in the Python script via suds?
UPD: After I commented out the cache settings when creating the client object, queries began to work adequately with suds.null () as an argument. How can this be connected, and what do I need to do to ensure that everything works when the cache is enabled?