Closed gcobr closed 2 years ago
@gcobr if you're using suds-py3, that fork of the upstream suds repo has diverged substantially from this repo which is based on the suds-jurko fork.
@gcobr for what it's worth, I've seen similar oddities in other APIs. One way to accomplish sending the raw XML is to use the __inject
key. For example:
v = client.service.ExecuteXMLRequest(__inject={'msg':b"<inteflow><something>value</something></inteflow>"})
You might also be able to construct the XML and pass it in via the suds.sax.text.Raw
type.
@gcobr for what it's worth, I've seen similar oddities in other APIs. One way to accomplish sending the raw XML is to use the
__inject
key. For example:v = client.service.ExecuteXMLRequest(__inject={'msg':b"<inteflow><something>value</something></inteflow>"})
You might also be able to construct the XML and pass it in via the
suds.sax.text.Raw
type.
@phillbaker I experimented with __inject
, and it replaces the entire SOAP envelope instead of injecting the desired content into the body.
I also tried client.service.ExecuteXMLRequest(suds.sax.text.Raw("<inteflow><something>value</something></inteflow>"))
, which doesn't inject anything into the body either.
@gcobr you can also write a plugin that hooks in to the marshalling process, see the example in: https://github.com/suds-community/suds#messageplugin and https://bitbucket.org/jurko/suds/issues/138/sax-element-prexif-namespaces-handling#comment-44111703
The way I do this is:
from suds.sax.text import Raw
fields = ''
for k, v in iter(customFields.items()):
if v:
field = Raw(f'<customField identifier="{k}">{v}</customField>')
else:
field = Raw(f'<customField identifier="{k}"/>')
fields += field
self.service.methodName(auth=self.auth, customFields=fields)
Another option:
from suds.client import _SoapClient, Client
client = Client(...)
method = client.wsdl.services[0].ports[0].methods[operation_name]
message = method.binding.input.get_message(method, args, kwargs) # or build your own
sc = SoapClient(method.client, method)
sc.send(message)
History of this in suds-jurko/suds:
Using suds-py3.
When loading the following WSDL:
https://clientdev.inteflow.com.au/inteport/DecisionGateway.asmx?WSDL
I get:
The types list contains all this, but nothing called
_sRequestXML
(which should be treated as a string, I reckon):Then, when I do:
The SOAP string I passed to
ExecuteXMLRequest
is not set as the value ofns1:ExecuteXMLRequest
. Instead, the element is empty:I need Suds to produce an envelope like this instead:
Is there a problem with the WSDL? Should I pass the parameter in some other way?
Full example: