【问题标题】:How to translate SOAP message to webServiceTemplate.sendSourceAndReceiveToResult of SPRING WS如何将 SOAP 消息转换为 SPRING WS 的 webServiceTemplate.sendSourceAndReceiveToResult
【发布时间】:2013-10-01 07:59:27
【问题描述】:

我的soapUI 上有一个SOAP 消息调用

<soapenv:Envelope xmlns:cen="http://netadmin.ghl.com/centralizedconfig" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
       <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" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
             <wsse:UsernameToken wsu:Id="UsernameToken-21">
                <wsse:Username>admin</wsse:Username>
                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">secret</wsse:Password>
                <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">xo6ADfFZ5aqvukQZjUb6IQ==</wsse:Nonce>
                <wsu:Created>2013-10-01T06:59:20.202Z</wsu:Created>
             </wsse:UsernameToken>
             <wsu:Timestamp wsu:Id="TS-20">
                <wsu:Created>2013-10-01T06:58:47.521Z</wsu:Created>
                <wsu:Expires>2013-10-01T07:10:47.521Z</wsu:Expires>
             </wsu:Timestamp>
          </wsse:Security>
       </soapenv:Header>
       <soapenv:Body>
          <cen:GetXMLRequest>
             <cen:IpAddress>10.36.28.211</cen:IpAddress>
          </cen:GetXMLRequest>
       </soapenv:Body>
    </soapenv:Envelope>

每当我在我的 SOAP UI 上运行它来测试我的 Web 服务时,它都能完美运行, 我在使用 webServiceTemplate.sendSourceAndReceiveToResult 调用翻译这条肥皂消息时遇到了困难,我是网络服务的新手 而且我不知道如何将标题消息合并到我的代码中。 有人可以帮我弄这个吗?

客户调用:

webServiceTemplate.sendSourceAndReceiveToResult (网址、来源、结果);

我似乎无法在 source 参数中包含安全标头

【问题讨论】:

  • 你的spring配置文件中配置拦截器了吗?
  • 谢谢伙计,我真的已经通过使用 spring 配置我的客户端来解决这个问题

标签: java soap ws-security spring-ws wss4j


【解决方案1】:

我在我的 Spring 客户端应用程序上下文中添加了一个拦截器

    <bean id="wss4jSecurityInterceptor"
    class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
       <property name="securementActions" value="UsernameToken" />
       <property name="securementUsername" value="user" />
       <property name="securementPassword" value="password" />
       <property name="validationCallbackHandler" ref="callbackHandler" />
    </bean>

【讨论】:

  • 我不明白这个解决方案...您在客户端使用安全拦截器?这如何修改您的客户端肥皂头以创建您提到的 wsse:Security 头参数
猜你喜欢
  • 1970-01-01
  • 2011-07-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-11
  • 2014-07-01
  • 1970-01-01
  • 2013-12-22
相关资源
最近更新 更多