我正在尝试设置子节点的命名空间,但它们没有设置
public static final String WSSE_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
public static final String PWD_TEXT_TYPE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText";
public static final String WSSE_SECURITY_NAME = "Security";
public static final String WSSE_NS_PREFIX = "wsse";
SOAPElement securityName = envelope.getHeader().addChildElement(WSSE_SECURITY_NAME, WSSE_NS_PREFIX, WSSE_NS);
SOAPElement userNameToken = securityName.addChildElement("Usernametoken", WSSE_NS_PREFIX, WSSE_NS);
SOAPElement usernameNS = userNameToken.addChildElement("UserName", WSSE_NS_PREFIX, WSSE_NS);
这个输出是:
<SOAP-ENV:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" mustUnderstand="1">
<wsse:Usernametoken>
<wsse:UserName></wsse:UserName>
</wsse:Usernametoken>
</wsse:Security>
</SOAP-ENV:Header>
命名空间刚刚消失:(