【问题标题】:How to authenticate ws-security soap header with jaxws on a tomcat server如何在 tomcat 服务器上使用 jaxws 验证 ws-security soap 标头
【发布时间】:2013-01-12 01:41:14
【问题描述】:

我使用 JAX-WS RT 开发了一个简单的 Web 服务,并将其部署在 Tomcat 6 服务器上。我需要使用 SOAP 标头中的 ws-security 来验证对我的 Web 服务的调用。

我的方法是使用链处理程序来提取soap 标头中的用户名和密码并在我的代码中进行身份验证。这是正确的方法吗?如果不是,正确的方法是什么?

使用soapUI,我通过以下标头发送了

 <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">  
     <wsse:UsernameToken> 
        <wsse:Username>test</wsse:Username> 
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">test</wsse:Password> 
     </wsse:UsernameToken> 
  </wsse:Security> 

使用此标头我收到以下错误

  <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
  <S:Body>
  <SOAP-ENV:Fault xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
     <faultstring>MustUnderstand headers:[{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security] are not understood</faultstring>
     <faultcode>SOAP-ENV:MustUnderstand</faultcode>
  </SOAP-ENV:Fault>

使用 JAX-WS rt 如何设置我的 Web 服务以接受这种类型的标头并进行身份验证。

【问题讨论】:

    标签: jax-ws tomcat6 ws-security soapheader


    【解决方案1】:

    使用链式处理程序是处理 ws-security 标头的一种方式,它与诸如壁垒之类的框架相比只是一种较低级别的方法(尽管这些框架通常只是为您实现这些处理程序)。如果您编写自己的消息处理程序,则必须覆盖

    Set<QName> getHeaders()
    

    声明你理解的标题。在这种情况下,返回一个包含

    的集合
    QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security")
    

    为了避免“MustUnderstand”错误。

    【讨论】:

    猜你喜欢
    • 2015-04-13
    • 1970-01-01
    • 2020-12-16
    • 2011-04-26
    • 1970-01-01
    • 1970-01-01
    • 2012-09-22
    • 1970-01-01
    • 2016-11-08
    相关资源
    最近更新 更多