5

I need to create a ruby web service client(with Savon) to make a soap call to a web service which requires the EncodingType in the Nonce. So the correct soap message will have the Nonce element like this:

......
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">SomeHashValue</wsse:Nonce>
......

But in my Savon client, I don't know how to add that attribute in the Nonce element. My code here:

......
client = Savon.client do
  wsdl.endpoint = "http://webservicehost/TestWebService"
  wsdl.namespace = "namespace"
  wsse.credentials "username", "password"
  wsse.digest = "true"
end
client.request :get_service do |soap|
  soap.input = [ 
    "GetService", 
    { "xmlns" => "namespace" } 
  ]
soap.body = {
    "locale" => "en_US",
    "serviceID" => '123'
  } 
end
......

and the Nonce in the generated SOAP message is like:

 ......
    <wsse:Nonce>SomeHashValue</wsse:Nonce>
 ......

So my question is, how to add the attribute EncodingType to the Nonce element, without changing/removing the SomeHashValue in the Nonce element?

Don
  • 555
  • 3
  • 12

1 Answers1

3

I've had success modifying the gems\akami-1.2.1\lib\akami\wsse.rb file's def wsse_username_token method.

I don't know the best way but this does work, merely add to the :attributes!.

Before:

:attributes! => { "wsse:Password" => { "Type" => PASSWORD_DIGEST_URI } }

After:

:attributes! => { "wsse:Password" => { "Type" => PASSWORD_DIGEST_URI }, "wsse:Nonce" => { "EncodingType" => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'} }
Lifeweaver
  • 986
  • 8
  • 29