Class: Savon::SOAP::RequestBuilder
- Inherits:
-
Object
- Object
- Savon::SOAP::RequestBuilder
- Defined in:
- lib/savon/soap/request_builder.rb
Overview
= Savon::SOAP::RequestBuilder
Savon::SOAP::RequestBuilder builds Savon::SOAP::Request instances. The RequestBuilder is configured by the client that instantiates it. It uses the options set by the client to build an appropriate request.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the attributes of the SOAP input tag.
-
#config ⇒ Object
Returns the Savon::Config object for the request.
-
#http ⇒ Object
Returns the HTTPI::Request object.
-
#namespace_identifier ⇒ Object
Returns the identifier for the default namespace.
-
#operation ⇒ Object
readonly
Reader for the operation of the request being built by the request builder.
-
#soap ⇒ Object
Returns the SOAP::XML object.
-
#soap_action ⇒ Object
Returns the SOAP action.
-
#wsdl ⇒ Object
Returns the Wasabi::Document object.
-
#wsse ⇒ Object
Returns the Akami::WSSE object.
Instance Method Summary collapse
-
#body ⇒ Object
Returns the body of the SOAP request.
-
#body=(body) ⇒ Object
Changes the body of the SOAP request to +body+.
-
#initialize(operation, options = {}) ⇒ RequestBuilder
constructor
Initialize a new +RequestBuilder+ with the given SOAP operation.
-
#input_namespace_identifier ⇒ Object
Returns the namespace identifier to be used for the the SOAP input tag.
-
#namespace ⇒ Object
Returns the default namespace to be used for the SOAP request.
-
#operation_namespace_defined_in_wsdl? ⇒ Boolean
Returns true if the operation's namespace is defined within the WSDL document.
-
#request(&post_configuration_block) ⇒ Object
Builds and returns a Savon::SOAP::Request object.
-
#soap_input_tag ⇒ Object
Returns the SOAP operation input tag.
Constructor Details
#initialize(operation, options = {}) ⇒ RequestBuilder
Initialize a new +RequestBuilder+ with the given SOAP operation. The operation may be specified using a symbol or a string.
13 14 15 16 |
# File 'lib/savon/soap/request_builder.rb', line 13 def initialize(operation, = {}) @operation = operation () end |
Instance Attribute Details
#attributes ⇒ Object
Returns the attributes of the SOAP input tag. Defaults to an empty Hash.
137 138 139 |
# File 'lib/savon/soap/request_builder.rb', line 137 def attributes @attributes ||= {} end |
#config ⇒ Object
Returns the Savon::Config object for the request. Defaults to a clone of Savon.config.
143 144 145 |
# File 'lib/savon/soap/request_builder.rb', line 143 def config @config ||= Savon.config.clone end |
#http ⇒ Object
Returns the HTTPI::Request object.
148 149 150 |
# File 'lib/savon/soap/request_builder.rb', line 148 def http @http ||= HTTPI::Request.new end |
#namespace_identifier ⇒ Object
Returns the identifier for the default namespace. If an operation namespace identifier is defined for the current operation in the WSDL document, this namespace identifier is used. Otherwise, the +@namespace_identifier+ instance variable is used.
66 67 68 69 70 71 72 |
# File 'lib/savon/soap/request_builder.rb', line 66 def namespace_identifier if operation_namespace_defined_in_wsdl? wsdl.operations[operation][:namespace_identifier].to_sym else @namespace_identifier end end |
#operation ⇒ Object (readonly)
Reader for the operation of the request being built by the request builder.
44 45 46 |
# File 'lib/savon/soap/request_builder.rb', line 44 def operation @operation end |
#soap ⇒ Object
Returns the SOAP::XML object.
153 154 155 |
# File 'lib/savon/soap/request_builder.rb', line 153 def soap @soap ||= XML.new(config) end |
#soap_action ⇒ Object
Returns the SOAP action. If +@soap_action+ has been defined, this will be returned. Otherwise, if there is a WSDL document defined, the SOAP action corresponding to the operation will be returned. Failing this, the operation name will be used to form the SOAP action.
104 105 106 107 108 109 110 111 112 |
# File 'lib/savon/soap/request_builder.rb', line 104 def soap_action return @soap_action if @soap_action if wsdl.document? wsdl.soap_action(operation.to_sym) else Gyoku::XMLKey.create(operation).to_sym end end |
#wsdl ⇒ Object
Returns the Wasabi::Document object.
158 159 160 |
# File 'lib/savon/soap/request_builder.rb', line 158 def wsdl @wsdl ||= Wasabi::Document.new end |
#wsse ⇒ Object
Returns the Akami::WSSE object.
163 164 165 |
# File 'lib/savon/soap/request_builder.rb', line 163 def wsse @wsse ||= Akami.wsse end |
Instance Method Details
#body ⇒ Object
Returns the body of the SOAP request.
131 132 133 |
# File 'lib/savon/soap/request_builder.rb', line 131 def body soap.body end |
#body=(body) ⇒ Object
Changes the body of the SOAP request to +body+.
126 127 128 |
# File 'lib/savon/soap/request_builder.rb', line 126 def body=(body) soap.body = body end |
#input_namespace_identifier ⇒ Object
Returns the namespace identifier to be used for the the SOAP input tag. If +@namespace_identifier+ is not +nil+, it will be returned. Otherwise, the default namespace identifier as returned by +namespace_identifier+ will be returned.
78 79 80 |
# File 'lib/savon/soap/request_builder.rb', line 78 def input_namespace_identifier @namespace_identifier || namespace_identifier end |
#namespace ⇒ Object
Returns the default namespace to be used for the SOAP request. If a namespace is defined for the operation in the WSDL document, this namespace will be returned. Otherwise, the default WSDL document namespace will be returned.
85 86 87 88 89 90 91 |
# File 'lib/savon/soap/request_builder.rb', line 85 def namespace if operation_namespace_defined_in_wsdl? wsdl.parser.namespaces[namespace_identifier.to_s] else wsdl.namespace end end |
#operation_namespace_defined_in_wsdl? ⇒ Boolean
Returns true if the operation's namespace is defined within the WSDL document.
95 96 97 98 |
# File 'lib/savon/soap/request_builder.rb', line 95 def operation_namespace_defined_in_wsdl? return false unless wsdl.document? (operation = wsdl.operations[self.operation]) && operation[:namespace_identifier] end |
#request(&post_configuration_block) ⇒ Object
Builds and returns a Savon::SOAP::Request object. You may optionally pass a block to the method that will be run after the initial configuration of the dependencies. +self+ will be yielded to the block if the block accepts an argument.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/savon/soap/request_builder.rb', line 50 def request(&post_configuration_block) configure_dependencies if post_configuration_block # Only yield self to the block if our block takes an argument args = [] and (args << self if post_configuration_block.arity == 1) post_configuration_block.call(*args) end Request.new(config, http, soap) end |
#soap_input_tag ⇒ Object
Returns the SOAP operation input tag. If there is a WSDL document defined, and the operation's input tag is defined in the document, this will be returned. Otherwise, the operation name will be used to form the input tag.
117 118 119 120 121 122 123 |
# File 'lib/savon/soap/request_builder.rb', line 117 def soap_input_tag if wsdl.document? && (input = wsdl.soap_input(operation.to_sym)) input else Gyoku::XMLKey.create(operation) end end |