SOAPFault wrongly assumes that the hash keys will be symbols #393
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First of all, thank you for making this excellent gem.
I like to use the
convert_tags_to: nil
option with Savon so that it will work with some legacy code that requires the response hash keys to be CamelCase strings. However, the SOAPFault class assumes the response hash keys will be snake_case symbols, which is the default. As a result, if a SOAP fault occurs and the error handling code tries to callto_s
orto_hash
on the SOAPFault exception we get another exception (undefined method '[]' for nil:NilClass
). This is bad because it makes it hard for me to see the actual error message returned by the server. Also, developers probably don't expect that callingto_s
will raise another exception.This pull request contains some new rspec examples in
soap_fault_spec.rb
that demonstrate the problem.How do you think we should solve this? I see two reasonable options:
parse
, but ignores the two special options that affect keys (strip_namespaces
andconvert_tags_to
). Use this method in the SOAPFault class so that that the keys in the hash will be predictable.Nori::XMLUtilityMode
. Use this method in the SOAPFault class so that we can be sure to access the right hash key, not matter what it is.I think option 1 is cleaner, but option 2 might be better because we can then use it to make
Savon::Response#body
andSavon::Response#header
work properly. ( However I see from here that the you have already considered that and decided against it. )Thanks!