I have a camera on my network which I am trying to connect to with suds but suds doesn’t send all the information needed. I need to put extra soap headers not defined in the WSDL file so the camera can understand the message. All the headers are contained in a SOAP envelope and then the suds command should be in the body of the message.
I have checked the suds website
and it says to pass in the headers like so: (This passes in the element as a header but I have an envelope so I’m not sure how to input this)
from suds.sax.element import Element
client = client(url)
ssnns = ('ssn', 'http://namespaces/sessionid')
ssn = Element('SessionID', ns=ssnns).setText('123')
client.set_options(soapheaders=ssn)
result = client.service.addPerson(person)
Now, I am not sure how I would implement this. Say for example, I have the below header:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP
ENC="http://www.w3.org/2003/05/soap-encoding"
<wsa:MessageID SOAP-ENV:mustUnderstand="true">urn:uuid:43268c01-f09c6</wsa:MessageID>
<SOAP-ENV:Header>
Using this or a similar example does anyone know how I would pass a valid SOAP message to the targeted service?
Thanks
I have worked out how to enter in new headers and namespaces in suds.
As stated above you create an Element and pass it in as a soapheader as so:
But if you would like to add a namespace I have found adding a prefix seem’s to do the trick. So when you create one of the elements you add
addPrefix. I’m not sure if this was the way it was intended to be done but it work’s.The
p = 'SOAP-ENC'can be any prefixeg. wsaand theu = http://addressis the address of the namespace.A complete script that would run could be:
This moves the camera. To change the type of soap-envelope check my next question.
You can add logging into this script whci allow’s you to check what xml command you have sent which is handy:
The location can be put into the script as an option if the location is not in the wsdl file.