我有一个问题,我认为是关于命名空间的。可以从这里下载WSDL:http://promostandards.org/content/wsdl/Order%20Shipment%20NotificationService/1.0.0/OSN-1-0-0.zip
生成请求时,它看起来像这样:
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://www.promostandards.org/WSDL/OrderShipmentNotificationService/1.0.0/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<tns:GetOrderShipmentNotificationRequest>
<tns:wsVersion>1.0.0</tns:wsVersion>
<tns:id>myusername</tns:id>
<tns:password>mypassword</tns:password>
<tns:queryType>3</tns:queryType>
<tns:shipmentDateTimeStamp>2017-07-19</tns:shipmentDateTimeStamp>
</tns:GetOrderShipmentNotificationRequest>
</soapenv:Body>
</soapenv:Envelope>
这会导致肥皂故障。
当SoapUI使用相同的WSDL构造请求时,它看起来像这个
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.promostandards.org/WSDL/OrderShipmentNotificationService/1.0.0/" xmlns:shar="http://www.promostandards.org/WSDL/OrderShipmentNotificationService/1.0.0/SharedObjects/">
<soapenv:Header/>
<soapenv:Body>
<ns:GetOrderShipmentNotificationRequest>
<shar:wsVersion>1.0.0</shar:wsVersion>
<shar:id>myusername</shar:id>
<shar:password>mypassword</shar:password>
<ns:queryType>3</ns:queryType>
<ns:shipmentDateTimeStamp>2017-07-19</ns:shipmentDateTimeStamp>
</ns:GetOrderShipmentNotificationRequest>
</soapenv:Body>
</soapenv:Envelope>
您可以看到SoapUI已将用户名和密码放在&#34; shar&#34;命名空间。我注意到这并没有直接列在WSDL或WSDL直接加载的任何XSD文件中。它被加载像WSDL =&gt; XSD文件=&gt;包含shar命名空间的XSD文件。这可能是问题吗?如何将命名空间添加到3个键中?我使用的是savon 2.11.1和nori 2.6.0
以下是我最终使用的解决方案:
@client = Savon.client(
wsdl: 'OSN-1-0-0/WSDL/1.0.0/OrderShipmentNotificationService.wsdl',
endpoint: @endpoint,
env_namespace: :soapenv,
namespaces: { "xmlns:shar" => "http://www.promostandards.org/WSDL/OrderShipmentNotificationService/1.0.0/SharedObjects/" },
element_form_default: :qualified,
headers: { "accept-encoding" => "identity" }
)
response = @client.call(:get_order_shipment_notification, message: {
'shar:ws_version': @version,
'shar:id': @username,
'shar:password': @password,
query_type: 3,
shipment_date_time_stamp: date
})
答案 0 :(得分:0)
我认为Savon没有解释链接的XSD文件,这里使用它来引用SharedObject。有一个类似的问题,我发现的唯一解决方案是手动编写命名空间的定义。
在您的情况下,它可能看起来像这样:
array (
'foo' =>
array (
'bar' => '',
'bat' => 'Cricket',
),
'qux' =>
array (
'quux' => '',
),
)