我正在使用 jax-ws 从 JAVA 调用使用 WS-Security 的 SOAP 服务。 问题是响应包含一些 MustUnderstand header ,并且我收到 Element notunderstanded SoapFaultException。
响应 header 如下所示:
<s:Header>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<u:Timestamp u:Id="_0">
<u:Created>2011-12-19T15:38:49.023Z</u:Created>
<u:Expires>2011-12-19T15:43:49.023Z</u:Expires>
</u:Timestamp>
</o:Security>
我可以为该 header 添加一个虚拟 SOAPHandler 吗?或者也许将其修改为mustUnderstand =“0”?以及如何?
最佳答案
错过了重写handler中的getHeaders()方法。重写getHeaders()方法
@Override
public Set<QName> getHeaders() {
final QName securityHeader = new QName(
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
"Security",
"wsse");
final HashSet headers = new HashSet();
headers.add(securityHeader);
// notify the runtime that this is handled
return headers;
}
关于java - 如何为 {http ://docs. oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd} 添加虚拟 SOAPHandler?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8563985/