Class: Soaspec::BasicSoapHandler
- Defined in:
- lib/soaspec/basic_soap_handler.rb
Overview
Wraps around Savon client defining default values dependent on the soap request
Instance Attribute Summary collapse
-
#client ⇒ Object
Savon client used to make SOAP calls.
-
#default_operation ⇒ Object
SOAP Operation to use by default.
-
#namespaces ⇒ Object
Namespaces used in XML body.
Attributes inherited from Tester
Instance Method Summary collapse
-
#call(options) ⇒ SavonResponse
Sends a call to the API (is being made obsolete).
- #default_hash=(hash) ⇒ Object
- #include?(value) ⇒ Boolean
-
#initialize(name, specific_options) ⇒ BasicSoapHandler
constructor
Setup object to handle communicating with a particular SOAP WSDL.
-
#make_request(override_parameters) ⇒ Object
TODO: Use this together with Exchange request.
- #name(name) ⇒ Object
- #override(request_parameters) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, specific_options) ⇒ BasicSoapHandler
Setup object to handle communicating with a particular SOAP WSDL
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/soaspec/basic_soap_handler.rb', line 17 def initialize(name, ) super = { ssl_verify_mode: :none, follow_redirects: true, # Necessary log: true, # See request and response. (Put this in traffic file) log_level: :debug, logger: file_logger, soap_version: 2, # use SOAP 1.2. You will get 415 error if this set to default pretty_print_xml: true, # Prints XML pretty raise_errors: false } .merge!() @client = Savon.client() self.namespaces = {} @name = name end |
Instance Attribute Details
#client ⇒ Object
Savon client used to make SOAP calls
9 10 11 |
# File 'lib/soaspec/basic_soap_handler.rb', line 9 def client @client end |
#default_operation ⇒ Object
SOAP Operation to use by default
13 14 15 |
# File 'lib/soaspec/basic_soap_handler.rb', line 13 def default_operation @default_operation end |
#namespaces ⇒ Object
Namespaces used in XML body
11 12 13 |
# File 'lib/soaspec/basic_soap_handler.rb', line 11 def namespaces @namespaces end |
Instance Method Details
#call(options) ⇒ SavonResponse
Sends a call to the API (is being made obsolete)
38 39 40 41 42 43 44 |
# File 'lib/soaspec/basic_soap_handler.rb', line 38 def call() test_values = [:overide_values]['request'] || {} # Empty hash if no specific request values are set [:operation] ||= self.default_operation # Erb parses template file, executing Ruby code in `<% %>` blocks to work out final request render_body = ERB.new([:template]).result(binding) @client.call([:operation], xml: render_body ) # Call the SOAP operation with the request XML provided end |
#default_hash=(hash) ⇒ Object
80 81 82 83 |
# File 'lib/soaspec/basic_soap_handler.rb', line 80 def default_hash=(hash) @request_option = :hash @default_hash = hash end |
#include?(value) ⇒ Boolean
76 77 78 |
# File 'lib/soaspec/basic_soap_handler.rb', line 76 def include?(value) @xml_response.include? value end |
#make_request(override_parameters) ⇒ Object
TODO: Use this together with Exchange request
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/soaspec/basic_soap_handler.rb', line 58 def make_request(override_parameters) test_values = override_parameters # Used in Erb # Erb parses template file, executing Ruby code in `<% %>` blocks to work out final request puts 'O' + override_parameters.to_s if @request_option == :template request_body = File.read('template/' + template_name + '.xml') render_body = ERB.new(request_body).result(binding) @client.call(default_operation, xml: render_body ) # Call the SOAP operation with the request XML provided elsif @request_option == :hash @client.call(default_operation, message: @default_hash) end end |
#name(name) ⇒ Object
46 47 48 49 50 |
# File 'lib/soaspec/basic_soap_handler.rb', line 46 def name(name) @test_values = {} @test_name = name self end |
#override(request_parameters) ⇒ Object
52 53 54 55 |
# File 'lib/soaspec/basic_soap_handler.rb', line 52 def override(request_parameters) @test_values = request_parameters self end |
#to_s ⇒ Object
71 72 73 74 |
# File 'lib/soaspec/basic_soap_handler.rb', line 71 def to_s Soaspec::Environment.api_handler = self @name end |