Skip to content

rich/serviceproxy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ServiceProxy

ServiceProxy is a lightweight SOAP library for Ruby. 

How it works

Loading the library:

require 'rubygems'
require 'service_proxy'

Using the library:

Unlike SOAP4R, this library takes a very different approach to building 
requests and parsing responses. There is little magic and no code 
generation with this library. 

You will need to understand some simple things about SOAP before you
can use this library. Using a tool like SOAPUI or SoapClient, you can
easily get enough information to use this library with existing SOAP
services.

For each service endpoint you want to connect to, you will need to 
subclass ServiceProxy.

Let's say you want to call the method cool1 on a service:

First, you create a subclass:

class SuperCoolService < ServiceProxy
  
  def build_cool1(options)
    # This will generate a simple SOAP envelope. Using the xml block local, you 
    # can inject XML into the body of the envelope.
    soap_envelope(options) do |xml|
      # your XML here
    end
  end
  
  def parse_cool1(response)
    # The response parameter is a simple Net::HTTP response
    # here, we use Hpricot to parse it, but you could use
    # Nokogiri, REXML, etc
    xml = Hpricot.XML(response.body)
    xml.at("cool1Result").inner_text
  end
end

Next, you can attempt to call the service:

service = SuperCoolService.new(url_to_wsdl)
service.cool1

CONTRIBUTORS

Rich Cavanaugh

About

Lightweight SOAP library for Ruby

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%