Problem with situation in SOAP message tag names using savon

I am using Ruby 1.9.2 with savon 0.9.2 on Windows 7 Professional 64 bit.

I need to call the SOAP web service, which requires the security token that I get from the second SOAP web service. The code I use is as follows:

require 'savon'

client = Savon::Client.new "http://some.url?wsdl"
client.wsdl.soap_actions

start_session_response = client.request :start_session do
  soap.input = ["StartSession", {:xmlns => "http://some.schema" } ]
  soap.body = { :userName => "User", :password => "password" }
end

do_something_response = client.request :do_something do
  soap.input = [ "DoSomething", { :xmlns => "http://some.schema"} ]
  soap.body = { :securityToken => start_session_response.to_hash[:start_session_response][:security_token] }
end

The result is XML, which looks like this:

<?xml version="1.0" encoding="utf-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wsdl="http://some.schema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Body>
    <DoSomething xmlns="http://some.schema">
      <wsdl:securityToken>
        <wsdl:tokenType>sessiontoken</wsdl:tokenType>
        <wsdl:token>
         .
        .
        .
        </wsdl:token>
      </wsdl:securityToken>
    </DoSomething>
  </env:Body>
</env:Envelope>

Ignore the weird namespace convention (or is it just me) in this XML, which is a savona that does its job.

The problem I am facing is that the tags inside the securitytoken tag start with a lowercase letter, where they should be in upper case. Therefore, <tokenType>they <token>should have been <tokenType>and <token>.

-, WSDL, Savon. , , .

, XML/SOAP ?

+5
3

Savon Gyoku , . , :

Gyoku.convert_symbols_to :camelcase # or one of [:none, :lover_camelcase]

, .

+9

Savon "" convert_request_keys_to Savon:

# In Savon 2
Savon.client wsdl:"http://some.url?wsdl", convert_request_keys_to: :camelcase

, accepts one of :lower_camelcase, :camelcase, :upcase, or :none.

+16

I had a similar problem with Savon and ended up using strings instead of characters for my hash keys, you could try something like:

soap.body = { 'TokenType'=> 'some_value', 'Token' => 'some_value' }
+11
source

All Articles