Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ruby savon and wsdl namespacing

I have an issue that I believe is in regards to namespaces. The WSDL can be downloaded from here: http://promostandards.org/content/wsdl/Order%20Shipment%20NotificationService/1.0.0/OSN-1-0-0.zip

When the request is generated it looks like this:

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

This results in a soap fault.

When SoapUI constructs the request using the same WSDL it looks like this

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

You can see that SoapUI has placed the username and password inside the "shar" namespace. I noticed that this is not directly listed in the WSDL or in any XSD file directly loaded by the WSDL. It gets loaded something like WSDL => XSD file => XSD file containing shar namespace. could that be the issue? How can I add the namespace to just 3 of the keys? I'm using savon 2.11.1 and nori 2.6.0

Here is the solution I ended up using:

@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
})
like image 482
Cryptographic_ICE Avatar asked Nov 08 '22 19:11

Cryptographic_ICE


1 Answers

I think Savon doesn't interpret linked XSD files, which are used here to reference the SharedObject. Had a similar problem and the only solution I found was to manually write the definition of the namespaces.

In your case it might look something like this:

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
like image 174
skahlert Avatar answered Nov 15 '22 10:11

skahlert