【问题标题】:How to resolve failure of JAX_WS web service invocation "MustUnderstand headers are not understood"?如何解决 JAX_WS Web 服务调用失败“MustUnderstand 标头不被理解”?
【发布时间】:2011-05-21 01:52:59
【问题描述】:

我正在使用 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


    【解决方案1】:

    您可以为{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>
    

    【讨论】:

    • 我很想看到更多关于“为 {docs.oasis-open.org/wss/2004/01/…}Security 配置一个虚拟 SOAPHandler 以将此标头标记为‘已理解’。”
    • 我也想看看这样一个假的 SOAP Handler
    • 只需实现一个SOAPHandler,它从getHeaders() 返回{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security,但其handle.. 方法什么也不做(返回true)。就是这样。
    • 在我的情况下,甚至没有来电SOAPHandler&lt;SOAPMessageContext&gt;,它远离SoapMessageDispatcherhandleHeaders()。请指导stackoverflow.com/questions/60260277/…
    【解决方案2】:

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

    【讨论】:

    • 啊,架构过度的规范又一次阻碍了完成工作。
    【解决方案3】:
    【解决方案4】:

    在 SOAP UI 导航器中,

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

    【讨论】:

      【解决方案5】:

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

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

      【讨论】:

      猜你喜欢
      • 2011-02-20
      • 2011-10-04
      • 1970-01-01
      • 1970-01-01
      • 2015-03-28
      • 1970-01-01
      • 2014-05-22
      • 2016-07-06
      • 1970-01-01
      相关资源
      最近更新 更多