XML SOAP request by Ruby?

General discussion on technical and managerial topics
no avatar
martinnitram
 
Posts: 1
Joined: Tue May 03, 2011 2:54 am

XML SOAP request by Ruby?

by martinnitram » Tue May 03, 2011 3:10 am

Dears,

I need to send a XML SOAP request to a WS (by Ruby). The same is as follows:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:StreetWSDL" 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:Put>
      <authKey xsi:type="xsd:string">mySecretKey</authKey>
      <ArrayOfInterfaceObjInput SOAP-ENC:arrayType="ns1:InterfaceObjInput[1]" xsi:type="ns1:ArrayOfInterfaceObjInput">
        <item xsi:type="ns1:InterfaceObjInput">
          <idEntradaCaller xsi:type="xsd:string"/>
          <idInterface xsi:type="xsd:string"/>
          <idEstado xsi:type="xsd:string"/>
          <asyncronic xsi:type="xsd:string"/>
          <fechaDiferido xsi:type="xsd:string"/>
          <idCliente xsi:type="xsd:string"/>
          <idEmpresa xsi:type="xsd:string"/>
          <idVenta xsi:type="xsd:string"/>
          <idVentaPadre xsi:type="xsd:string"/>
          <idServicio xsi:type="xsd:string"/>
          <idProducto xsi:type="xsd:string"/>
          <idServicioPadre xsi:type="xsd:string"/>
          <idProductoPadre xsi:type="xsd:string"/>
          <idPromotor xsi:type="xsd:string"/>
          <xmlEncoding xsi:type="xsd:string"/>
        </item>
      </ArrayOfInterfaceObjInput>
      <doAtomic xsi:type="xsd:string">0</doAtomic>
    </ns1:Put>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


The questions are:
Is there any way to make a request by Ruby?
What are the gems that would be needed?

I appreciate any format or example code.

Thank you very much for the help.

Sincerely,

no avatar
daniel88
 
Posts: 11
Joined: Thu Dec 27, 2012 12:37 pm
Location: VIET NAM

»

by daniel88 » Sat Jan 26, 2013 10:58 am

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

Return to General Discussion