简体   繁体   中英

How to make this soap request using savon

Could someone explain me how can I use savon to make this soap request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ent="some_adress">
   <soapenv:Header>
      <ent:providerID>?</ent:providerID>
   </soapenv:Header>
   <soapenv:Body>
      <ent:operationRequest>
         <ent:operation>
            <!--You may enter the following 2 items in any order-->
            <ent:id>operation_id</ent:id>
            <ent:params>
               <!--1 or more repetitions:-->
               <ent:entry>
                  <ent:key>param1_name</ent:key>
                  <ent:value>param1_valuee</ent:value>
               </ent:entry>
               <ent:entry>

                  <ent:key>param2_name</ent:key>
                  <ent:value>param2_value</ent:value>
               </ent:entry>
            </ent:params>
         </ent:operation>
      </ent:operationRequest>
   </soapenv:Body>
</soapenv:Envelope>

This soap request I got in soapUI.

I tried this (not to make a request, but to see how savon will generate the soap request):

test_message = {:param_1_name => 'param 1 value', :param_2_name => 'param 2 value'}

    ops = wsdl_client.operation(:request_operation)
    ops.build(message: test_message).to_s

And the result was very different from the soapUi request:

<?xml version="1.0" encoding="UTF-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="some_adress" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="some_adress">
    <env:Header>
        <ent:providerID>999</ent:providerID>
    </env:Header>
    <env:Body>
        <ins0:operationRequest>
            <ns1:param1Name>param 1 value</ns1:param1Name>
            <ns1:param2Name>param 2 value</ns1:param2Name>
        </ins0:operationRequest>
    </env:Body>
</env:Envelope>

I couldn't figure it out how to add this 'entries' to a savon request.

Thank you gyus!

I find out a way to do it.

request = {
      operation: {
          id: '123',
          params: [
              entry: [{
                  key: 'param1',
                  value: '9999999'
              },
              {
                  key: 'param2',
                  value: 'ASD'
              }]
          ]
      }
  }

I wrote this hash and passed it as the message in the call method.

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM