SOAP Client with Ruby and Savon: How to Add EncodingType Attribute to Nonce Element

I need to create a ruby ​​web service client (with Savon) in order to make a soap call to a web service that requires EncodingType in Nonce. So, the correct soap message will have a Nonce element as follows:

......
<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 do not know how to add this attribute to the Nonce element. My code is 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
......

Nonce in the generated SOAP message looks like this:

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

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

+5
source share
1 answer

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

, , :attributes!.

:

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

:

: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'} }
+3

All Articles