Skip to content

Instantly share code, notes, and snippets.

@tommi-lew
Created June 20, 2012 06:14
Show Gist options
  • Save tommi-lew/2958404 to your computer and use it in GitHub Desktop.
Save tommi-lew/2958404 to your computer and use it in GitHub Desktop.
Ruby SOAP Client
#Part of a school project using SAP ERP.
#Created a composite application using a Linux EC2 Instance & created SOAP web services.
#Used Ruby to invoke enterprises services in SAP.
require 'rubygems'
require 'savon'
client = Savon::Client.new do
wsdl.document = File.read("wsdl_document.wsdl")
http.auth.basic "username", "password"
end
#print all the operations in the service
client.wsdl.soap_actions.each { |i| puts i }
response = client.request :yq1, :operation_name do
soap.namespaces["xmlns:SOAP-ENV"] = "http://schemas.xmlsoap.org/soap/envelope/"
soap.namespaces["xmlns:xs"] = "http://www.w3.org/2001/XMLSchema"
soap.namespaces["xmlns:xsi"] = "http://www.w3.org/2001/XMLSchema-instance"
soap.xml = '<?xml version="1.0" encoding="utf-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body>...</SOAP-ENV:Body></SOAP-ENV:Envelope>'
end
#Reference: http://fagiani.github.com/savon/
#Note: The XML is hardcoded.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment