Hi there
I’m in the process of trying to communicate with a web service that requires a user login.
The login information has to be passed as part of the SOAP Header of the message when the Login method of the web service is called.
So after connecting successfully to the web service I’ve set a callback procedure on the web service that builds the XML for the SOAP request header.
When I’m building the SOAP header elements I output the XML I’ve built to a file to check that I’ve built it correctly (with all the correct elements and attributes). I'm using the usual X-DOCUMENT / X-NODEREF objects to buid the XML manually.
I’ve run the code and trapped the XML that is being passed to the web service by using a network analyzer program called Ethereal.
What I’ve noticed (and what is causing me an issue as the web service is expecting this to be passed) is that the elements in my SOAP header do not contain any of the attributes that I’ve assigned to them.
For example, the XML file that I’ve saved directly from my code using the x-document:save("FILE", "header.xml") method contains the following XML element
<ns0:Security soap:misUnderstand="1"
xmlns:ns0="http://schemas.xmlsoap.org/ws/2002/07/secext">
<ns0:UsernameToken
wsu:Id="LOGIN"
xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility">
<ns0:Username>abc</ns0:Username>
<ns0
<wsu:Created>2006-08-15T12:12:32Z</wsu:Created>
</ns0:UsernameToken>
</ns0:Security>
This is exactly what I want. Notice the 2 attributes of the UsernameToken element (wsu:Id and xmlns:wsu). I’m no SOAP expert, and I’m not really interested in whether this is good or bad SOAP XML, all I know is that this is what the web service requires (I have a sample XML file showing what the header needs to be, and this is it).
This element was built as an X-NODEREF object, added to a SOAP-HEADER-ENTRYREF object using the SET-NODE method, and then this SOAP-HEADER-ENTRYREF added to the SOAP-HEADER object using ADD-HEADER-ENTRY, and it is this SOAP-HEADER that is returned by the callback procedure to create the header of the SOAP message.
When I intercept the SOAP message going to my web service, this is what I see as part of the soap header for the element above
<ns0:Security soap:mustUnderstand="1"
xmlns:ns0="http://schemas.xmlsoap.org/ws/2002/07/secext">
<ns0:UsernameToken>
<ns0:Username>abc</ns0:Username>
<ns0
<wsu:Created>2006-08-15T12:13:50Z</wsu:Created>
</ns0:UsernameToken>
</ns0:Security>
The attributes I mentioned earlier are now no longer part of the UsernameToken element that is being sent to the web service. It’s as if the SET-NODE or ADD-HEADER-ENTRY methods that added my X-NODEREF object to the SOAP header have removed / ignored any attributes that I set when building the X-NODEREF object.
Does anyone have any ideas as to how I can ensure that these attributes remain in my SOAP header message ?