2017-07-26 74 views
6

我有一個問題,我相信是關於命名空間。該WSDL可從這裏下載:http://promostandards.org/content/wsdl/Order%20Shipment%20NotificationService/1.0.0/OSN-1-0-0.zip紅寶石savon和wsdl命名空間

當產生請求時,它看起來是這樣的:

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

這將導致一個SOAP錯誤。

當了SoapUI構建使用它看起來像這樣

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

同一個WSDL可以看到了SoapUI已經把用戶名和密碼的「沙皮」命名空間裏的請求。我注意到這並不是直接列在WSDL中,或者直接由WSDL加載的任何XSD文件中。它得到加載類似於WSDL => XSD文件=>包含shar命名空間的XSD文件。這可能是問題嗎?我怎樣才能將命名空間添加到3個鍵?我正在使用savon 2.11.1和nori 2.6.0

回答

0

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