0

我需要模拟一个通过soap 标头接收身份验证凭据的soap 服务。有没有办法使用wash_out gem 访问/解析soap 头?

<SOAP-ENV:Header>
    <ns:credentials xmlns:ns="http://somedomain.com/ws">
        <ns:userID ns:encodingType="xsd:string">User</ns:userID>
        <ns:password ns:encodingType="xsd:string">Password</ns:password>
    </ns:credentials>
</SOAP-ENV:Header>
4

1 回答 1

1

Wash_out 仅支持 WSSE(Web 服务安全)身份验证。

它看起来像这样:

<soap:Header>        
  <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2003/06/secext">
   <wsse:UsernameToken wsu:Id="sample" 
       xmlns:wsu="http://schemas.xmlsoap.org/ws/2003/06/utility">
    <wsse:Username>sample</wsse:Username>
    <wsse:Password Type="wsse:PasswordText">oracle</wsse:Password>
    <wsu:Created>2004-05-19T08:44:51Z</wsu:Created>
   </wsse:UsernameToken>
  </wsse:Security>
 </soap:Header>

我相信,如果您使用的是wash_out,您可以获得类似这样的标题(我没有尝试过这段代码,我只是在看https://github.com/inossidabile/wash_out/blob/master/lib/wash_out /调度程序.rb

envelope = request.env['wash_out.soap_data'].values_at(:envelope, :Envelope).compact.first
header   = envelope.values_at(:header, :Header).compact.first
userId = header.values_at(:userID, :UserID).compact.first
password = header.values_at(:password, :Password).compact.first
于 2014-05-13T02:09:42.720 回答