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

Handling duplicate elements in soap request #251

Open
Ramanpreetsingh opened this issue Mar 7, 2018 · 3 comments
Open

Handling duplicate elements in soap request #251

Ramanpreetsingh opened this issue Mar 7, 2018 · 3 comments

Comments

@Ramanpreetsingh
Copy link

Ramanpreetsingh commented Mar 7, 2018

I have a soap request where I'll be getting duplicate elements (Unique ID in the request given below) in soap request. But I can't find a way to define these elements in the args parameter.

The SOAP request is :

<OTA_CancelRQ Version="2.1" EchoToken="201403211421"
 xmlns="http://www.opentravel.org/OTA/2003/05"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

 <UniqueID ID="859623" Type="501"/>

 <UniqueID ID="ABCDEF" Type="502"/>

 <UniqueID ID="123456" Type="10"/>

 <Reasons>
 <Reason>business plan changed</Reason>
 </Reasons>
</OTA_CancelRQ>

Here is the code in my wash out controller :

soap_service namespace: 'urn:WashOut'

    soap_action "OTA_CancelRQ",
                  :args => {
                    :OTA_CancelRQ =>{

                      :UniqueID => {
                        :@ID => :integer,
                        :@Type => :integer
                      },
                      :Reasons => [{:Reason => :string }]
                    }},
                  :return => :string,
                  :to => :cancel_booking

These args generate a WSDL with with only one UniqueId element. I have tried defining the UniqueId multiple times in the args but it is generating only one UniqueId element.

@CR4567
Copy link

CR4567 commented Mar 7, 2018

hm... I'm not a specialist for building the parameters but if I understand right, I would assume a list for unique IDs like
<IDS> <UniqueID ID="859623" Type="501"/> <UniqueID ID="ABCDEF" Type="502"/> <UniqueID ID="123456" Type="10"/> </IDS>

and then you could use it in the params with
:IDS => [ :UniqueID => { :@ID => :integer, :@Type => :integer }]

I don't know if you can have a list of elements without having an element that builds the list.

@Ramanpreetsingh
Copy link
Author

It's not a list of elements, these are stand alone XML elements.

@dangarcia
Copy link

You can attempt to use Nori to parse your XML structure https://github.com/savonrb/nori
Then use the generated hash as your soap_action args

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

No branches or pull requests

3 participants