2013-10-01 38 views
4

我在更改SOAP xml的命名空間時遇到問題。我不知道如何改變 「的xmlns:ENV =」 到 「的xmlns:soapenv =」 和 「的xmlns:TNS =」 到 「的xmlns:網絡=」Ruby/Savon:遇到肥皂請求的命名空間問題

我試圖建立:

​​

什麼我目前得到

<?xml version="1.0" encoding="UTF-8"?> 
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://www.webserviceX.NET/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <env:Body> 
     <tns:ConvertTemp> 
     <tns:temperature>100</tns:temperature> 
     <tns:fromUnit>degreeCelsius</tns:fromUnit> 
     <tns:toUnit>degreeFahrenheit</tns:toUnit> 
     </tns:ConvertTemp> 
    </env:Body> 
</env:Envelope> 

我的代碼:

client = Savon.client(wsdl: "http://www.webservicex.net/ConvertTemperature.asmx?WSDL") 
message = { temperature: '100',FromUnit: 'degreeCelsius' , ToUnit: 'degreeFahrenheit'} 
response = client.call(:convert_temp, message: message) 

感謝您的幫助。

回答

11

我能弄清楚如何改變這些。如果有人有興趣的方式來改變這些是:

client = Savon.client(env_namespace: :soapenv,namespace_identifier: :web) 

這實際上並沒有造成我的問題,雖然。事實證明,我的領域沒有我注意到了。 「FromUnit」變成「fromUnit」。

+0

我有同樣的肥皂問題,你能解釋一下你是如何解決這個問題的嗎? –

+1

將此添加到您的clientconvert_request_keys_to::none, –