如何为{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}添加虚拟SOAPHandler?

时间:2011-12-19 16:03:50

标签: java java-ee soap jax-ws

我正在使用jax-ws调用使用JAVA的WS-Security的SOAP服务。 问题是响应包含一些mustUnderstand头,我得到的元素不能理解SoapFaultException

响应标题如下所示:

 <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>

我可以为该标头添加虚拟SOAPHandler吗?或者修改为mustUnderstand =“0”?怎么样?

1 个答案:

答案 0 :(得分:0)

错过覆盖handler.Override 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;
    }