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

XML arguments in operation/action tag under savon 2.0 #361

Closed
courtland opened this issue Jan 10, 2013 · 10 comments
Closed

XML arguments in operation/action tag under savon 2.0 #361

courtland opened this issue Jan 10, 2013 · 10 comments

Comments

@courtland
Copy link
Contributor

Hi. I am currently in the process of upgrading to savon 2.x from 1.2 and have hit a bit of a wall. I have an obscure API that I must use that requires arguments other than the operation name to be in the SOAP action tag.

For example:

<soapenv:Body>

   <inn:PostTransactionRQ PosID="ABC321" RoomID="128" Surname="HERNANDEZ">

      <inn:Service Code="WWW" ReferenceID="123456C" Quantity="2"/>

      <inn:Price AmountAfterTax="0.01" CurrencyCode="USD" DecimalPlaces="2">

         </inn:Price>

   </inn:PostTransactionRQ>

</soapenv:Body>

In savon 1.x I had something like:

response = client.request('inn', 'postTransactionRQ',
  # attributes! hash
  { 'PosID' => 'ABC321',
    'RoomID' => '128',
    'Surname' => 'HERNANDEZ'
  }
) do
  soap.body = { ... }
end

Where the second and third arguments to the request method yielded an action tag of:

<inn:PostTransactionRQ PosID="ABC321" RoomID="128" Surname="HERNANDEZ">

So far under savon 2.0 I have not been able to figure out a way to force Gyoku to use an !attributes hash when generating the action/operation tag. I've even looked through the latest Savon code to no avail.

I would prefer to not have to generate the entire message and use the :xml option (overriding Savon Builder). Is there something I am overlooking to accomplish this or can it be added as an option in a new release? Thanks!

@michalgritzbach
Copy link

I have exactly the same problem, looking forward for an answer.

@rubiii
Copy link
Contributor

rubiii commented Jan 10, 2013

can someone provide a wsdl for testing please?

@courtland
Copy link
Contributor Author

I'll email you the WSDL I was given. Its for a closed hotel PMS system. I'm
not sure if it correctly indicates the need for the XML attributes I
mentioned, but its all I was able to get from my customer and we were
successfully integrated with their API using savon 1.2 and this WSDL.

Thanks.

On Thu, Jan 10, 2013 at 5:25 AM, Daniel Harrington <notifications@github.com

wrote:

can someone provide a wsdl for testing please?


Reply to this email directly or view it on GitHubhttps://github.com//issues/361#issuecomment-12096296.

@rubiii
Copy link
Contributor

rubiii commented Jan 10, 2013

thanks for the wsdl. so the good news is that savon 2.x correctly parses the operation names.
so calling that operation from your issue is as simple as this:

client.call(:post_transaction)

you can get a list of all operations names via:

client.operations

but unfortunately, there is no way of adding attributes to the tag right now.
i'll come up with a fix for this.

@courtland
Copy link
Contributor Author

Yes, everything works great except for adding those attributes. I had a relatively easy time of migrating the syntax given your excellent documentation. There is another action that I use that doesn't require attributes in the action tag and I was able to get it to work.

For the moment I have downgraded back to savon 1.2 until we can add attributes to the action tag.

Thanks!

rubiii added a commit that referenced this issue Jan 10, 2013
@rubiii
Copy link
Contributor

rubiii commented Jan 10, 2013

pushed the local :attributes option to master. please give it a try:

attributes = { 'PosID' => 'ABC321', 'RoomID' => '128', 'Surname' => 'HERNANDEZ' }
client.call(:post_transaction, attributes: attributes)

@courtland
Copy link
Contributor Author

Works great now. Thanks!

Can I expect this as an official gem anytime soon? If not I'll go ahead with just using master.

@rubiii
Copy link
Contributor

rubiii commented Jan 10, 2013

it will be in the next release. i don't have a release date for this yet, but i'll keep you posted.

@courtland
Copy link
Contributor Author

Sounds good. Thanks.

@amoludage
Copy link

@rubiii 👍

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

4 participants