views:

595

answers:

1

I want to make a request to a SOAP Web Service but I don't want to install any gems. Is there any way to just make the request using plain XML?

I think it's trivial but there might be something I've missed, because all implementations/tutorials were using a gem.

I think that the SOAP response, can be handled also as a XML response right?

The request is this:

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"&gt;
  <soap12:Body>
    <Tick xmlns="http://demo.com/test/test"&gt;
      <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>
+2  A: 

You could do this:

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 would be returned by this method.

BigCanOfTuna