1

I need to hit a SOAP service, however, the server won't accept my request but throws an error due to the below header and footer in the request.

As per the logs, the request/response looks like below:

SOAP **request**: http://www.url.co.au/wserv/wslms.php
SOAPAction: "insertlmsdata", Content-Type: text/xml;charset=UTF-8, Content-Length: 938
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="urn:lmsdataautomation" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Body>
    <tns:insertlmsdata>
      <lmsinfo>
        <userCred>
          <clientCode>code</clientCode>
          <username>name</username>
          <password>ee#@!</password>
        </userCred>
        <lead>
          <requestno>3</requestno>
          <firstname>Meckinsey</firstname>
          <lastname>Meth</lastname>
          <email>meckinsey.meth@er.com</email>
          <mobileno>4233333333</mobileno>
          <keyword>Romali</keyword>
          <requestMessage>looking for Romali</requestMessage>
          <responseMessage>Romadd</responseMessage>
          <operator>you</operator>
          <circle>Romaon</circle>
          <requestDate>20-04-2017</requestDate>
          <shortCode>2222</shortCode>
          <category>DOM</category>
          <city>Sydney</city>
          <destination>Perth</destination>
        </lead>
      </lmsinfo>
    </tns:insertlmsdata>
  </env:Body>
</env:Envelope>

HTTPI POST request to www.egggo.co.au (excon)
SOAP **response** (status 200)
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:lmsdataautomation" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body>
    <ns1:insertlmsdataResponse>
      <output xsi:type="xsd:string">&lt;output&gt;Either parsed xml is not valid or contains special chars like &amp; "'&lt;/output&gt;</output>
    </ns1:insertlmsdataResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I have looked thoroughly Savon Documentation, couldn't find anything relevant. Can I configure Savon to not add headers, footer, envelope and just the body?

Basically to ignore the below data:

SOAP request: http://www.url.co.au/wserv/wslms.php SOAPAction: "insertlmsdata", Content-Type: text/xml;charset=UTF-8, Content-Length: 938

Otherwise, the SOAP server rejects the request. Please help, TIA

Adding the body of the request:

client = Savon.client(wsdl: url, log: true, logger: Rails.logger, log_level: :debug, pretty_print_xml: true, encoding: 'UTF-8')

response = client.call(:insertlmsdata, message: {'lmsinfo'=> {'userCred'=> {'clientCode' => 'code', 'username' => 'dom', 'password' => '#pass'  }, 'lead' => {'requestno' => 3, 'firstname'=>'Methyl', 'lastname'=> 'Orange', 'email' => 'methyl.orange@egg.com', 'mobileno' => '55555555', 'keyword' => 'atlanta', 'requestMessage' => 'looking for atlant', 'responseMessage' => 'dd', 'operator' => 'you', 'circle' => 'sydney', 'requestDate' => '04-20-2017', 'shortCode' => 2222, 'category'=> 'DOM', 'city' => 'Sydney', 'destination' => 'Atlanta' } } })
cop
  • 93
  • 3
  • 10
  • Please clarify, are those headers part of the _body_ of the request? Or are they http headers proper? Also, what footer are you talking about? And can you show us the wsdl? For what it's worth, the response looks like the request made it to the server, but the server couldn't parse the payload. This indicates that savon is working properly, but that something is wrong with the body of the request. Are there any [special characters](https://docs.oracle.com/cd/A97336_01/buslog.102/bc4j/developing_bc_projects/obcCustomXml.htm) in your request that aren't beings escaped? – Glyoko Apr 20 '17 at 18:53
  • Hi Glyoko, I am not setting headers in the body, these are prepended by the savon gem. Footers is the envelope closing. I don't see any special characters. I have added the body of the request in the question itself. – cop Apr 23 '17 at 04:35
  • Could you post the link to the wsdl? In the line that says `Savon.client(wsdl: url ...`, what is the url? – Glyoko Apr 24 '17 at 19:06
  • Figured out, it was a bug at the wsdl server side. Thanks Glyoko for the help – cop Apr 26 '17 at 07:29

0 Answers0