2

I'm trying to use Savon(2.3) to make a SOAP request with Ruby, but I'm receiving a 500 error code from server .

Server response :-

SOAP response (status 500) D, [2014-03-04T11:44:03.824902 #10771] DEBUG -- : soap:ServerSystem.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1. at System.Xml.XmlTextReaderImpl.Throw(Exception e)

Ruby code :-

require 'savon'

client = Savon.client(encoding: "UTF-8",env_namespace: :soapenv,namespace_identifier:    :web, wsdl:'http://www3.experian.co.za/webservice/getreport.asmx?wsdl')
xml = '<![CDATA[<InputData>test data in beteween </InputData>]]>'
message = {
"Input" => xml
}
response = client.call(:get_report,:message => message)

Request i wants to create :-

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://localhost/WebService/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:GetReport>
         <!--Optional:-->
         <web:Input><![CDATA[<InputData>(Text data in between)</InputData>]]></web:Input>
      </web:GetReport>
   </soapenv:Body>
</soapenv:Envelope>

I have tested it with soapui tool and i am getting response correctly but not with savon ruby client.

Sanjeev
  • 298
  • 4
  • 11

1 Answers1

0

You can use Gyoku not to escape the characters in CDATA.

https://github.com/savonrb/gyoku/blob/master/README.md

message Gyoku.xml(data: "</body></xml>]]>"