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

Version 1.2.0 generate invalid body XML from hashes. #321

Closed
skoona opened this issue Sep 18, 2012 · 7 comments
Closed

Version 1.2.0 generate invalid body XML from hashes. #321

skoona opened this issue Sep 18, 2012 · 7 comments

Comments

@skoona
Copy link

skoona commented Sep 18, 2012

Question: Help me understand how to fix these problem, or should I just wait for the next update?

It doesn't work is the wrong way to start any bug report; but it does accurately indicate how confused I am in trying to describe the failures I see. I'm using savon in a rails 3.2.7 application under development and I wrote the web services routines two months ago and covered them with rspec tests. Those tests suddenly failed last nite, as a result of a 'bundle update' causing the savon version to move to 1.2.0.

I see two errors types which seem to be caused by a hash_to_xml conversion.

      // (1) this 
     { include_deleted: [false]  }

      // should produce the following   
     <ins0:includeDeleted>
        false
      </ins0:includeDeleted>

     // but instead produces
    <ins0:includeDeleted xsi:nil="true"/>

     // (2) this 
    document_ref:  {
       "Id" => doc_id,
       "RefId" => doc_ref_id
     }

   // should produce
    <ins0:documentRef>
        <ins0:Id>
          c02ac7af-aed0-4582-895b-827d4c1a3ae5
        </ins0:Id>
        <ins0:RefId>
          11353223
        </ins0:RefId>
      </ins0:documentRef>

   // but instead produces
   <ins0:documentRef>
        <ins0:Id>
          #&lt;WebServices::IRCategory:0x63bbc3ee&gt;
        </ins0:Id>
        <ins0:RefId>
          #&lt;WebServices::IRCategory:0x61312de3&gt;
        </ins0:RefId>
      </ins0:documentRef>

Example (A) below is the output generated by version 1.1.0, and example (B) is the output from version 1.2.0. Example be causes a soap fault. The following is a snippet from the savon call.

      body = {
          security_token: @session,
          document_ref:  {
              "Id" => doc_id,
              "RefId" => doc_ref_id
          },
          include_deleted: [false]
      }

      result = []
      response = @client.request :get_pages, :body => body

example (A) Good

2012-09-18 00:14:31.298 AC3:DEBUG <?xml version="1.0"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://imageright.com/imageright.webservice" xmlns:tns="http://imageright.com/imageright.webservice" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Body>
    <ins0:GetPages>
      <ins0:securityToken>
        6230e819-264f-4eaa-bb6d-e1db299af650
      </ins0:securityToken>
      <ins0:documentRef>
        <ins0:Id>
          c02ac7af-aed0-4582-895b-827d4c1a3ae5
        </ins0:Id>
        <ins0:RefId>
          11353223
        </ins0:RefId>
      </ins0:documentRef>
      <ins0:includeDeleted>
        false
      </ins0:includeDeleted>
    </ins0:GetPages>
  </env:Body>
</env:Envelope>

example (B) Bad

2012-09-17 23:53:20.316 AC3:DEBUG <?xml version="1.0"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://imageright.com/imageright.webservice" xmlns:tns="http://imageright.com/imageright.webservice" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Body>
    <ins0:GetPages>
      <ins0:securityToken>
        e0ccee02-196d-44ff-9fee-fa949da88821
      </ins0:securityToken>
      <ins0:documentRef>
        <ins0:Id>
          #&lt;WebServices::IRCategory:0x63bbc3ee&gt;
        </ins0:Id>
        <ins0:RefId>
          #&lt;WebServices::IRCategory:0x61312de3&gt;
        </ins0:RefId>
      </ins0:documentRef>
      <ins0:includeDeleted xsi:nil="true"/>

    </ins0:GetPages>
  </env:Body>
</env:Envelope>
@timabdulla
Copy link
Member

would it be possible to provide the WSDL document you are using so that I can reproduce these errors?

@skoona skoona closed this as completed Sep 18, 2012
@skoona skoona reopened this Sep 18, 2012
@skoona
Copy link
Author

skoona commented Sep 18, 2012

ok, the wsdl is in this public Gist

git://gist.github.com/3744255.git

or

https://gist.github.com/3744255

@timabdulla
Copy link
Member

great, I'll take a look as soon as I can, thanks.

@rubiii
Copy link
Contributor

rubiii commented Dec 11, 2012

hey @skoona,

the good news is, i found out why savon creates a nil-tag for [false] values.

regarding the doc_id and doc_ref_id problem, i'm not 100% sure. by looking at the code i would guess that savon calls #to_s on these WebServices::IRCategory which defaults to #inspect in 1.9?!

try to add a #to_s method to your objects which returns the correct id or make sure to pass in a simple string or integer.

@rubiii rubiii closed this as completed in aa3ae5d Dec 11, 2012
@rubiii
Copy link
Contributor

rubiii commented Dec 11, 2012

pushed the fix. this will be included in the next release. thank you for reporting this problem.

@skoona
Copy link
Author

skoona commented Dec 22, 2012

rubiii,

I am able to confirm that #to_s on booleans formats the xml correctly. As a result I've upgraded to Savon 2.0.2 with only the required refactoring (i.e replace Savon.config and client request format.)

Thanks for your help.

@rubiii
Copy link
Contributor

rubiii commented Dec 22, 2012

awesome 😄

gregretkowski added a commit to gregretkowski/savon that referenced this issue Aug 22, 2014
This was fixed in savonrb#321, commit
aa3ae5d however it snuck
back into the code. This fixes it again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants