Module: SoapObject

Defined in:
lib/soap-object.rb,
lib/soap-object/factory.rb,
lib/soap-object/ssl_options.rb,
lib/soap-object/class_methods.rb

Overview

module to make it simpler to tests SOAP web services. The goal is to abstract all information about how your call and parse results from the web service within the soap objects.

class ZipCodeService

include SoapObject

wsdl 'http://www.webservicex.net/uszip.asmx?WSDL'

def get_zipcode_info(zip_code)
  get_info_by_zip 'USZip' => zip_code
end

def state
  message[:state]
end

message
  response.body[:get_info_by_zip_response][:get_info_by_zip_result][:new_data_set][:table]
end

end

There are many additional properties that can be set to configure the service calls. See the comments for SoapObject::ClassMethods to view all of the options.

Defined Under Namespace

Modules: ClassMethods, Factory Classes: SslOptions

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object (private)



103
104
105
106
107
108
# File 'lib/soap-object.rb', line 103

def method_missing(*args)
  operation =args.shift
  message = args.shift
  type = message.is_a?(String) ? :xml : :message
  call(operation, {type => message})
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



37
38
39
# File 'lib/soap-object.rb', line 37

def response
  @response
end

#wsdlObject (readonly)

Returns the value of attribute wsdl.



37
38
39
# File 'lib/soap-object.rb', line 37

def wsdl
  @wsdl
end

Class Method Details

.included(cls) ⇒ Object



43
44
45
# File 'lib/soap-object.rb', line 43

def self.included(cls)
  cls.extend SoapObject::ClassMethods
end

Instance Method Details

#bodyObject

Return the body of the message as a Hash



87
88
89
# File 'lib/soap-object.rb', line 87

def body
  response.body
end

#connected?Boolean

Returns true if the service has established communication with the remote server.

Returns:

  • (Boolean)


51
52
53
# File 'lib/soap-object.rb', line 51

def connected?
  not @client.nil?
end

#docObject

Return the response as a Nokogiri document



94
95
96
# File 'lib/soap-object.rb', line 94

def doc
  response.doc
end

#initialize(platform) ⇒ Object



39
40
41
# File 'lib/soap-object.rb', line 39

def initialize(platform)
  @client = platform.client(client_properties)
end

#operationsObject

Returns an array of operations that can be called on the remote service.



59
60
61
# File 'lib/soap-object.rb', line 59

def operations
  @client.operations
end

#to_hashObject

Return the response as a Hash



80
81
82
# File 'lib/soap-object.rb', line 80

def to_hash
  response.hash
end

#to_xmlObject

Return the xml response



66
67
68
# File 'lib/soap-object.rb', line 66

def to_xml
  response.to_xml
end

#xpath(path) ⇒ Object

Return value at xpath



73
74
75
# File 'lib/soap-object.rb', line 73

def xpath(path)
  response.xpath(path)
end