Skip to content

Commit

Permalink
translate the operation name to find the namespace
Browse files Browse the repository at this point in the history
translate the operation name to whatever the global :convert_request_keys_to
option was set to before trying to resolve the namespaces for a qualified message.

fixes #342.
  • Loading branch information
rubiii committed Dec 19, 2012
1 parent f7369ed commit 8da00e4
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/savon/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def to_s
return @message.to_s unless @message.kind_of? Hash

if @element_form_default == :qualified
@message = QualifiedMessage.new(@types, @used_namespaces, @request_key_converter).to_hash(@message, [@operation_name.to_s])
translated_operation_name = Gyoku.xml_tag(@operation_name, :key_converter => @key_converter).to_s
@message = QualifiedMessage.new(@types, @used_namespaces, @request_key_converter).to_hash(@message, [translated_operation_name])
end

gyoku_options = {
Expand Down
6 changes: 3 additions & 3 deletions lib/savon/qualified_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ def to_hash(hash, path)
return hash.to_s unless hash.kind_of? Hash

hash.inject({}) do |newhash, (key, value)|
camelcased_key = Gyoku.xml_tag(key, :key_converter => @key_converter).to_s
newpath = path + [camelcased_key]
translated_key = Gyoku.xml_tag(key, :key_converter => @key_converter).to_s
newpath = path + [translated_key]

if @used_namespaces[newpath]
newhash.merge(
"#{@used_namespaces[newpath]}:#{camelcased_key}" =>
"#{@used_namespaces[newpath]}:#{translated_key}" =>
add_namespaces_to_body(value, @types[newpath] ? [@types[newpath]] : newpath)
)
else
Expand Down
40 changes: 40 additions & 0 deletions spec/integration/ratp_example_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require "spec_helper"

describe "RATP example" do

it "retrieves information about a specific station" do
client = Savon.client do
# The WSDL document provided by the service.
wsdl "http://www.ratp.fr/wsiv/services/Wsiv?wsdl"

# Lower timeouts so these specs don't take forever when the service is not available.
open_timeout 10
read_timeout 10

# Disable logging for cleaner spec output.
log false
end

response = client.call(:get_stations) do
# For the corrent values to pass for :from_unit and :to_unit, I searched the WSDL for
# the "FromUnit" type which is a "TemperatureUnit" enumeration that looks like this:
#
# <s:simpleType name="TemperatureUnit">
# <s:restriction base="s:string">
# <s:enumeration value="degreeCelsius"/>
# <s:enumeration value="degreeFahrenheit"/>
# <s:enumeration value="degreeRankine"/>
# <s:enumeration value="degreeReaumur"/>
# <s:enumeration value="kelvin"/>
# </s:restriction>
# </s:simpleType>
#
# Support for XS schema types needs to be improved.
message(:station => { :id => 1975 }, :limit => 1)
end

station_name = response.body[:get_stations_response][:return][:stations][:name]
expect(station_name).to eq("Cite")
end

end

0 comments on commit 8da00e4

Please sign in to comment.