Hi trying to generate a security header in a Java Axis2 Client program in the format of.
<soapenv:Header>
<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/04/secext>
<wsse:UsernameToken>
<wsse:Username>myUsername</wsse:Username>
<wsse:Password>myPassword</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
using the following code
SOAPHeaderElement wsseSecurity = new SOAPHeaderElement(new PrefixedQName("http://schemas.xmlsoap.org/ws/2002/04/secext","Security", "wsse"));
MessageElement usernameToken = new MessageElement("", "wsse:UsernameToken");
MessageElement username = new MessageElement("", "wsse:Username");
MessageElement password = new MessageElement("", "wsse:Password");
username.setObjectValue(myProps.getProperty("username"));
usernameToken.addChild(username);
password.setObjectValue(myProps.getProperty("password"));
usernameToken.addChild(password);
wsseSecurity.addChild(usernameToken);
BookingPort bp = bsl.getBooking();
((Stub) bp).setHeader(wsseSecurity);
Unfortunately its not generating quite what I wanted and I get.
<soapenv:Header>
<wsse:Security soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/04/secext">
<wsse:UsernameToken xmlns:wsse="">
<wsse:Username xmlns:wsse="">myUsername</wsse:Username>
<wsse:Password xmlns:wsse="">myPassword</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
The service on the other end doesn't seem to handle the extra bits, resulting in an error
faultDetail:
{http://xml.apache.org/axis/}stackTrace:com.ctc.wstx.exc.WstxParsingException: Non-default namespace can not map to empty URI (as per Namespace 1.0 # 2) in XML 1.0 documents
at [row,col {unknown-source}]: [1,450]
How do I generate the SOAPHeader to not print out all the extra empty bits? Cheers