ruby savon和wsdl命名空间

我有一个问题,我认为是关于命名空间。 WSDL可以从这里下载: http : //promostandards.org/content/wsdl/Order%20Shipment%20NotificationService/1.0.0/OSN-1-0-0.zip

生成请求时,它看起来像这样:

   1.0.0 myusername mypassword 3 2017-07-19    

这导致肥皂故障。

当SoapUI使用相同的WSDL构造请求时,它看起来像这样

     1.0.0 myusername mypassword 3 2017-07-19    

您可以看到SoapUI已将用户名和密码放在“shar”命名空间内。 我注意到这并没有直接列在WSDL或WSDL直接加载的任何XSD文件中。 它被加载类似WSDL => XSD file =>包含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 }) 

我认为Savon不解释链接的XSD文件,这里使用它来引用SharedObject。 有一个类似的问题,我发现的唯一解决方案是手动编写命名空间的定义。

在你的情况下,它可能看起来像这样:

 client = Savon.client do endpoint "http://localhost/OrderShipmentNotificationService.svc" element_form_default :qualified namespace "http://www.promostandards.org/WSDL/OrderShipmentNotificationService/1.0.0/" namespace_identifier :ns namespaces "xmlns:shar"=>"http://www.promostandards.org/WSDL/OrderShipmentNotificationService/1.0.0/SharedObjects/" end response = client.call("GetOrderShipmentNotificationRequest") do |locals| locals.message "shar:wsVersion"=>"1.0.0","shar:id"=>"myusername",... end