Module: SoapObject

Includes:
Response
Defined in:
lib/soap-object.rb,
lib/soap-object/factory.rb,
lib/soap-object/version.rb,
lib/soap-object/response.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, Response Classes: SslOptions

Constant Summary collapse

VERSION =
"0.6.8"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Response

#body, #doc, #to_hash, #to_xml, #xpath

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(operation, body) ⇒ Object (private)



70
71
72
73
74
# File 'lib/soap-object.rb', line 70

def method_missing(operation, body)
  request = build_request(body)
  @response = @client.call(operation, request)
  response.to_xml
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

#wsdlObject (readonly)

Returns the value of attribute wsdl.



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

def wsdl
  @wsdl
end

Class Method Details

.included(cls) ⇒ Object



45
46
47
# File 'lib/soap-object.rb', line 45

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

Instance Method Details

#connected?Boolean

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

Returns:

  • (Boolean)


53
54
55
# File 'lib/soap-object.rb', line 53

def connected?
  not @client.nil?
end

#initialize(platform) ⇒ Object



41
42
43
# File 'lib/soap-object.rb', line 41

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

#operationsObject

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



61
62
63
# File 'lib/soap-object.rb', line 61

def operations
  @client.operations
end