有人可以解释我如何使用savon来发出这个肥皂请求:
<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>
我在soapUI中收到了这个肥皂请求。
我试过这个(不是提出请求,而是看看savon将如何生成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 :(得分:0)
我找到了办法。
request = {
operation: {
id: '123',
params: [
entry: [{
key: 'param1',
value: '9999999'
},
{
key: 'param2',
value: 'ASD'
}]
]
}
}
我写了这个哈希并将其作为调用方法中的消息传递。
谢谢!