Ruby on rails 如何使用Rails 4传递savon 2.7中的安全标头

Ruby on rails 如何使用Rails 4传递savon 2.7中的安全标头,ruby-on-rails,ruby,savon,Ruby On Rails,Ruby,Savon,我需要的标题是 <SOAP-ENV:Header xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:Security SOAP-ENV:mustUnderstand="1"> <wsse:UsernameToken> <wsse:Username>123</wsse:Username>

我需要的标题是

<SOAP-ENV:Header xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:Security SOAP-ENV:mustUnderstand="1">
<wsse:UsernameToken>
<wsse:Username>123</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">1234</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header> 
如何通过Savon 2.7中的标题我们无法访问服务,请帮助我们。

请尝试此操作(可在Savon 2文档中找到):


我接触的soap端点非常挑剔,我也有同样的问题。(wsse_auth不起作用)

我通过稍微修改你的答案解决了这个问题

  soap_header = {
        "wsse:Security" => {
            "@soapenv:mustUnderstand" => 1,
            "@xmlns:soap" => "http://schemas.xmlsoap.org/wsdl/soap/",
            "@xmlns:wsse" => "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
            "wsse:UsernameToken" =>{
                "wsse:Username"  => "123",
                "wsse:Password"  => "12345",
            }
        }
    }
问题是缺少soapenv:mustUnderstand=“1”

soap_header = {
        "wsse:Security" => {
            "@soapenv:mustUnderstand" => 1,
            "wsse:UsernameToken" =>{
                "Username"  => "123",
                "Password"  => "1234",
               "digest" => false
            }
        }
    }

client = Savon.client(wsdl: @wsdl, log: true,:ssl_verify_mode => :none,:soap_header=> soap_header)
response = client.call :getPIN, xml: @message
Savon.client(wsse_auth: ["123", "1234"])
  soap_header = {
        "wsse:Security" => {
            "@soapenv:mustUnderstand" => 1,
            "@xmlns:soap" => "http://schemas.xmlsoap.org/wsdl/soap/",
            "@xmlns:wsse" => "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
            "wsse:UsernameToken" =>{
                "wsse:Username"  => "123",
                "wsse:Password"  => "12345",
            }
        }
    }