0

wash_out(0.9.0) has been very helpful for me in implementing a SOAP service in my Rails(3.1) app. One little problem I am facing is that for XML payload in the SOAP body, < > are getting replaced by &lt; &gt;

Here's my code snippet

render :soap => "<person><firstname>larry</firstname></person>"

Output is

<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://www.w3.org/2001/12/soap-envelope"> <soap:Body> <tns:index_response> <value xsi:type="xsd:string">&lt;person&gt;&lt;firstname&gt;larry&lt;/firstname&gt;&lt;/person&gt;</value> </tns:index_response> </soap:Body> </soap:Envelope>

Is this a bug or can I fix this by some configuration or additional code. Kindly help.

Sagar Arlekar
  • 464
  • 4
  • 13

2 Answers2

1

Try this (didn't test it):

render :soap => "<person><firstname>larry</firstname></person>".html_safe
0

I was able to resolve this. There was 1 thing I was doing wrong.

I am using savon client to call my SOAP service. I was doing
client = Savon::Client.new(wsdl: "")
result = client.call(...)
puts result

This was displaying &lt; and &gt;

The right way to access the response content in my case is
result.body[:index_response][:value]
result.body returns a hash

With Nokogiri I could do doc = Nokogiri::XML(result.body.to_xml)

This works well with XML in payload.

Sagar Arlekar
  • 464
  • 4
  • 13