您好,試圖在Java Axis2客戶端程序中生成一個安全頭,格式爲。軸安全頭文件
<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>
使用下面的代碼
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);
遺憾的是它不產生完全是我想要的,我得到。
<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>
在另一端的服務似乎不處理額外的比特,從而導致錯誤
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]
如何產生的SOAPHeader不打印出所有多餘的空位? 乾杯
如何肥皂服務..please給出的示例代碼,我頭...... java和axis2 1.6.7 – 2015-11-14 05:30:08