So I need to consume a Web Service that uses a custom SoapHeader, as described below. What is the simplest way to pass the correct values through this header using Java. I’m using Netbeans.
<?xml version='1.0' encoding='utf-8'?\> <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> <soap:Header> <CustomSoapHeader xmlns='http://snip'> <UserName>'string'</UserName> <Password>'string'</Password> </CustomSoapHeader> </soap:Header> <soap:Body> <SomeWebMethod xmlns='http://snip' /> </soap:Body> </soap:Envelope>
EDIT: What’s the best way to display XML on Stack Overflow?
It might help to add that the Web Service is implemented in .NET and I cannot change the server side code.
Here are the basic steps, assuming you’re doing this on the client side:
You can pass parameters to your handler through the request context:
in handleMessage() you can get at the header like this:
Hope that helps. I’m guessing there’s also a way to do this stuff with annotations as well.