質問

I'm having trouble changing the namespace for the SOAP xml I'm building. I'm not sure how to change "xmlns:env=" to "xmlns:soapenv=" and "xmlns:tns=" to "xmlns:web="

What I'm trying to build:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:web="http://www.webserviceX.NET/">
    <soapenv:Header/>
    <soapenv:Body>
         <web:ConvertTemp>
             <web:Temperature>100</web:Temperature>
             <web:FromUnit>degreeCelsius</web:FromUnit>
             <web:ToUnit>degreeFahrenheit</web:ToUnit>
         </web:ConvertTemp>
    </soapenv:Body>
</soapenv:Envelope>

What I'm currently getting

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

My code:

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)

Thanks for the help.

役に立ちましたか?

解決

I was able to figure out how to change those. If anybody is interested the way to change those is:

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

That wasn't actually causing my problem though. Turns out that my fields were getting camelcased without me noticing. "FromUnit" became "fromUnit".

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top