3

my require header is

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

this is my message :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:dictionary:com.test.webservices">
<soapenv:Body>
<urn:getPIN/>
</soapenv:Body>
</soapenv:Envelope>

my code

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

how to pass header in Savon 2.7 we not able to access services please help us.

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
jayesh
  • 2,422
  • 7
  • 44
  • 78

2 Answers2

1

Try this please (found on Savon 2 documentation):

Savon.client(wsse_auth: ["123", "1234"])
0

The soap endpoint I was contacting was very picky and I had this same problem. (wsse_auth did not work)

I solved this by modifying your answer slightly.

  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",
            }
        }
    }

The problem was the missing soapenv:mustUnderstand="1"

Kieran Andrews
  • 5,845
  • 2
  • 33
  • 57