Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix namespaces not being properly added to arrays. #312

Merged
merged 1 commit into from
Aug 16, 2012
Merged

Fix namespaces not being properly added to arrays. #312

merged 1 commit into from
Aug 16, 2012

Conversation

timabdulla
Copy link
Member

When the SOAP request body is passed as a hash, one may specify the
value for a key to be an array of hashes. In this case, each hash
in the array is treated as being contained within a element specified by
the key. The namespace applied to the elements specified within the
array was previously the default namespace. This fix recursively
determines the proper namespaces for these elements.

  • Modify lib/savon/soap/xml.rb to recursively determine proper
    namespaces for elements contained within arrays
  • Modify spec/fixtures/wsdl/multiple_namespaces.xml to add a new
    operation that properly exhibits the problem
  • Modify spec/savon/client_spec.rb to add a new test that exhibits the
    problem
  • Modify spec/savon/client_spec.rb to change an old test that failed
    after the change. The failure was not a regression. In this case, the
    same namespace was applied but with a different namespace name.

When the SOAP request body is passed as a hash, one may specify the
value for a key to be an array of hashes. In this case, each hash
in the array is treated as being contained within a element specified by
the key. The namespace applied to the elements specified within the
array was previously the default namespace. This fix recursively
determines the proper namespaces for these elements.

- Modifiy lib/savon/soap/xml.rb to recursively determine proper
  namespaces for elements contained within arrays
- Modifiy spec/fixtures/wsdl/multiple_namespaces.xml to add a new
  operation that properly exhibits the problem
- Modifiy spec/savon/client_spec.rb to add a new test that exhibits the
  problem
- Modifiy spec/savon/client_spec.rb to change an old test that failed
  after the change. The failure was not a regression. In this case, the
  same namespace was applied but with a different namespace name.
@travisbot
Copy link

This pull request passes (merged f3ac4cc into c9d1f1b).


it "should namespaces each Array item as expected" do
HTTPI::Request.any_instance.expects(:body=).with do |value|
value.include?("<ins0:cartItems><ins0:CartItem>") && value.include?("<tns:ItemID>SKU-TEST</tns:ItemID>")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These hardcoded namespace references caused this test to fail after my patch. tns and ins0 actually refer to the same namespace. After my patch, ItemID will be namespaced by ins0 rather than tns. This change occurs because previously this element was just using the default namespace name. Note that the correctness of using tns or ins0 is the same, so I just generalized the test by referring to the actual namespace URI, rather than its name.

jkingdon added a commit that referenced this pull request Aug 16, 2012
Fix namespaces not being properly added to arrays.
@jkingdon jkingdon merged commit 3ad2787 into savonrb:master Aug 16, 2012
@rubiii
Copy link
Contributor

rubiii commented Sep 15, 2012

released with v1.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants