如何解决JAX_WS Web服务调用失败“MustUnderstand头文件无法理解”?

问题描述 投票:8回答:5

我正在使用SOAPUI工具访问Weblogic 10.3.2中部署的JAX-WS Web服务

请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.pc3.polk.com/"> <soapenv:Header> <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsu:Timestamp wsu:Id="Timestamp-1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsu:Created>2010-12-03T21:10:43Z</wsu:Created> <wsu:Expires>2010-12-03T21:44:03Z</wsu:Expires> </wsu:Timestamp> <wsu:Timestamp wsu:Id="Timestamp-60" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsu:Created>2010-12-03T20:10:39Z</wsu:Created> <wsu:Expires>2010-12-03T20:43:59Z</wsu:Expires> </wsu:Timestamp> <wsse:UsernameToken wsu:Id="UsernameToken-59" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsse:Username>rwerqre</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">ewrqwrwerqer</wsse:Password> <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">Nmw0ksmiOX+hkiSoWb2Rjg==</wsse:Nonce> <wsu:Created>2010-12-03T20:10:39.649Z</wsu:Created> </wsse:UsernameToken> </wsse:Security> </soapenv:Header> <soapenv:Body> <ws:getMetadata/> </soapenv:Body> </soapenv:Envelope>

响应:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <SOAP-ENV:Fault xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
         <faultcode>SOAP-ENV:MustUnderstand</faultcode>
         <faultstring>MustUnderstand headers:[{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security] are not understood</faultstring>
      </SOAP-ENV:Fault>
   </S:Body>
</S:Envelope>
web-services jax-ws webservice-client
5个回答
9
投票

您可以为{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security配置一个虚拟SOAPHandler,将此标头标记为“已理解”。

或者您可以更改SOAP请求(在调用方)以在安全标头中设置mustUnderstand="0"

使用mustUnderstand="0"的示例安全性SOAP标头:

<S:Header xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <wsse:Security S:mustUnderstand="0" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <wsse:UsernameToken>
         <wsse:Username>USERNAME</wsse:Username>
         <wsse:Password wsse:Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password>
      </wsse:UsernameToken>
   </wsse:Security>
</S:Header>


2
投票

根据WS安全规范:处理器必须在解密加密的头块之后,根据SOAP处理指南处理解密的头块。如果充分处理标头块所需的任何内容保持加密状态,或者解密的SOAP标头未被理解,并且解密的标头块上的S12:mustUnderstand或S11:mustUnderstand属性的值为true,则接收方必须引发故障。请注意,为了在这种情况下遵守SOAP处理规则,处理器必须回滚处理安全头的任何持久效果,例如存储接收到的令牌。所以请检查CallbackHandlers的配置。


2
投票

问题在于处理程序。您需要在处理程序实现中添加以下内容

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);
    return headers;
}

-1
投票

在SOAP UI Navigator中,

右键单击项目 - >显示项目视图 - > WS-Security配置 - >传出WS-Security配置取消选中必须了解,然后发送请求。

© www.soinside.com 2019 - 2024. All rights reserved.