I understand how to add a header to a SOAP request. But this creates a header that does not match the one I need to pass. This returns this header:
<SOAP-ENV:Header> <wsse:Security mustUnderstand="true"> <wsse:UsernameToken> <wsse:Username>CABLE</wsse:Username> <wsse:Password>CABLE</wsse:Password> </wsse:UsernameToken> </wsse:Security> </SOAP-ENV:Header>
However, I need to change the namespace of this header to pass a specific namespace for the Security object and the UsernameToken object. I cannot figure out how to override the default values.
<soapenv:Header> <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext"> http://schemas.xmlsoap.org/ws/2002/07/secext <wsse:UsernameToken xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility"> <wsse:Username>CABLE</wsse:Username> <wsse:Password Type="wsse:PasswordText">CABLE</wsse:Password> </wsse:UsernameToken> </wsse:Security> </soapenv:Header>
Here is the Python code to generate the above
security = Security() token = UsernameToken('CABLE', 'CABLE') security.tokens.append(token) client.set_options(wsse=security)
source share