2015-12-02 66 views
0

有人能解釋我如何使用薩翁使這個SOAP請求,使這個SOAP請求:如何使用薩翁

<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> 

這SOAP請求我的soapUI了。

我想這(不作要求,但看到薩翁將如何產生SOAP請求):

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 

,結果是從soapUI的要求很不同:

<?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> 

我無法弄清楚如何將這個'條目'添加到savon請求中。

謝謝gyus!

+0

看到這篇文章,如果有幫助http://stackoverflow.com/questions/22606875/trying-to-build-soap-request-with-savon – Rao

回答

0

我找到了一個方法來做到這一點。

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

我寫了這個散列並將其作爲消息傳遞給call方法。

謝謝!