Running a SOAP Request Using XML in Rails

I want to request a SOAP web service, but I don't want to install any gems. Is there a way to just make a request using simple XML?

I think this is trivial, but there might be something I missed because all implementations / tutorials used stone.

I think the SOAP response can be handled the same way as the XML response correctly?

The request is:

POST /services/tickets/issuer.asmx HTTP/1.1
Host: demo.demo.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <Tick xmlns="http://demo.com/test/test">
      <Request>
        <Username>string</Username>
        <Password>string</Password>
        <AcquirerId>int</AcquirerId>
        <RequestType>string</RequestType>
        <ExpirePreauth>unsignedByte</ExpirePreauth>
        <BitPerSec>int</BitPerSec>
        <Office>string</Office>
      </Request>
    </Tick>
  </soap12:Body>
</soap12:Envelope>
+5
source share
1 answer

You can do it:

def post_xml(path, xml)
  host = "http://demo.demo.com"
  http = Net::HTTP.new(host)
  resp = http.post(path, xml, { 'Content-Type' => 'application/soap+xml; charset=utf-8' })
  return resp.body
end

The XML response will be returned by this method.

+6
source

All Articles