Class: SOAP::RPC::Proxy
Defined Under Namespace
Classes: Operation
Constant Summary
Constants included from SOAP
AttrActor, AttrActorName, AttrArrayType, AttrArrayTypeName, AttrEncodingStyle, AttrEncodingStyleName, AttrHref, AttrHrefName, AttrId, AttrIdName, AttrMustUnderstand, AttrMustUnderstandName, AttrOffset, AttrOffsetName, AttrPosition, AttrPositionName, AttrRoot, AttrRootName, Base64Literal, EleBody, EleBodyName, EleEnvelope, EleEnvelopeName, EleFault, EleFaultActor, EleFaultActorName, EleFaultCode, EleFaultCodeName, EleFaultDetail, EleFaultDetailName, EleFaultName, EleFaultString, EleFaultStringName, EleHeader, EleHeaderName, EncodingNamespace, EnvelopeNamespace, LiteralNamespace, MediaType, NextActor, PropertyName, SOAPNamespaceTag, SOAPProxy, TypeMap, ValueArray, ValueArrayName, Version, XSDNamespaceTag, XSINamespaceTag
Instance Attribute Summary collapse
-
#allow_unqualified_element ⇒ Object
Returns the value of attribute allow_unqualified_element.
-
#default_encodingstyle ⇒ Object
Returns the value of attribute default_encodingstyle.
-
#driver_class ⇒ Object
Returns the value of attribute driver_class.
-
#filterchain ⇒ Object
readonly
Returns the value of attribute filterchain.
-
#generate_explicit_type ⇒ Object
Returns the value of attribute generate_explicit_type.
-
#headerhandler ⇒ Object
readonly
Returns the value of attribute headerhandler.
-
#http_logger ⇒ Object
Returns the value of attribute http_logger.
-
#literal_mapping_registry ⇒ Object
Returns the value of attribute literal_mapping_registry.
-
#mandatorycharset ⇒ Object
Returns the value of attribute mandatorycharset.
-
#mapping_registry ⇒ Object
Returns the value of attribute mapping_registry.
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
-
#return_response_as_xml ⇒ Object
Returns the value of attribute return_response_as_xml.
-
#soapaction ⇒ Object
Returns the value of attribute soapaction.
-
#streamhandler ⇒ Object
readonly
Returns the value of attribute streamhandler.
-
#use_default_namespace ⇒ Object
Returns the value of attribute use_default_namespace.
Instance Method Summary collapse
- #add_document_operation(soapaction, name, param_def, opt = {}) ⇒ Object (also: #add_document_method)
- #add_rpc_operation(qname, soapaction, name, param_def, opt = {}) ⇒ Object (also: #add_method, #add_rpc_method)
- #call(name, *params) ⇒ Object
- #check_fault(body) ⇒ Object
- #endpoint_url ⇒ Object
- #endpoint_url=(endpoint_url) ⇒ Object
-
#initialize(endpoint_url, soapaction, options) ⇒ Proxy
constructor
A new instance of Proxy.
- #inspect ⇒ Object
- #invoke(req_header, req_body, opt = nil) ⇒ Object
- #reset_stream ⇒ Object
- #route(req_header, req_body, reqopt, resopt, method_name = nil) ⇒ Object
- #set_wiredump_file_base(wiredump_file_base) ⇒ Object
- #test_loopback_response ⇒ Object
Constructor Details
#initialize(endpoint_url, soapaction, options) ⇒ Proxy
Returns a new instance of Proxy.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/soap/rpc/proxy.rb', line 49 def initialize(endpoint_url, soapaction, ) @endpoint_url = endpoint_url @soapaction = soapaction @options = @protocol_option = ["protocol"] ||= ::SOAP::Property.new initialize_streamhandler(@protocol_option) @operation = {} @operation_by_qname = {} @operation_by_soapaction = {} @mandatorycharset = nil # TODO: set to false by default or drop thie option in 1.6.0 @allow_unqualified_element = true @default_encodingstyle = nil @generate_explicit_type = nil @use_default_namespace = false @return_response_as_xml = false @headerhandler = Header::HandlerSet.new @filterchain = Filter::FilterChain.new @mapping_registry = nil @literal_mapping_registry = ::SOAP::Mapping::LiteralRegistry.new end |
Instance Attribute Details
#allow_unqualified_element ⇒ Object
Returns the value of attribute allow_unqualified_element.
33 34 35 |
# File 'lib/soap/rpc/proxy.rb', line 33 def allow_unqualified_element @allow_unqualified_element end |
#default_encodingstyle ⇒ Object
Returns the value of attribute default_encodingstyle.
34 35 36 |
# File 'lib/soap/rpc/proxy.rb', line 34 def default_encodingstyle @default_encodingstyle end |
#driver_class ⇒ Object
Returns the value of attribute driver_class.
44 45 46 |
# File 'lib/soap/rpc/proxy.rb', line 44 def driver_class @driver_class end |
#filterchain ⇒ Object (readonly)
Returns the value of attribute filterchain.
39 40 41 |
# File 'lib/soap/rpc/proxy.rb', line 39 def filterchain @filterchain end |
#generate_explicit_type ⇒ Object
Returns the value of attribute generate_explicit_type.
35 36 37 |
# File 'lib/soap/rpc/proxy.rb', line 35 def generate_explicit_type @generate_explicit_type end |
#headerhandler ⇒ Object (readonly)
Returns the value of attribute headerhandler.
38 39 40 |
# File 'lib/soap/rpc/proxy.rb', line 38 def headerhandler @headerhandler end |
#http_logger ⇒ Object
Returns the value of attribute http_logger.
45 46 47 |
# File 'lib/soap/rpc/proxy.rb', line 45 def http_logger @http_logger end |
#literal_mapping_registry ⇒ Object
Returns the value of attribute literal_mapping_registry.
43 44 45 |
# File 'lib/soap/rpc/proxy.rb', line 43 def literal_mapping_registry @literal_mapping_registry end |
#mandatorycharset ⇒ Object
Returns the value of attribute mandatorycharset.
32 33 34 |
# File 'lib/soap/rpc/proxy.rb', line 32 def mandatorycharset @mandatorycharset end |
#mapping_registry ⇒ Object
Returns the value of attribute mapping_registry.
42 43 44 |
# File 'lib/soap/rpc/proxy.rb', line 42 def mapping_registry @mapping_registry end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
47 48 49 |
# File 'lib/soap/rpc/proxy.rb', line 47 def operation @operation end |
#return_response_as_xml ⇒ Object
Returns the value of attribute return_response_as_xml.
37 38 39 |
# File 'lib/soap/rpc/proxy.rb', line 37 def return_response_as_xml @return_response_as_xml end |
#soapaction ⇒ Object
Returns the value of attribute soapaction.
31 32 33 |
# File 'lib/soap/rpc/proxy.rb', line 31 def soapaction @soapaction end |
#streamhandler ⇒ Object (readonly)
Returns the value of attribute streamhandler.
40 41 42 |
# File 'lib/soap/rpc/proxy.rb', line 40 def streamhandler @streamhandler end |
#use_default_namespace ⇒ Object
Returns the value of attribute use_default_namespace.
36 37 38 |
# File 'lib/soap/rpc/proxy.rb', line 36 def use_default_namespace @use_default_namespace end |
Instance Method Details
#add_document_operation(soapaction, name, param_def, opt = {}) ⇒ Object Also known as: add_document_method
103 104 105 106 107 |
# File 'lib/soap/rpc/proxy.rb', line 103 def add_document_operation(soapaction, name, param_def, opt = {}) ensure_styleuse_option(opt, :document, :literal) op = Operation.new(soapaction, param_def, opt) assign_operation(name, nil, soapaction, op) end |
#add_rpc_operation(qname, soapaction, name, param_def, opt = {}) ⇒ Object Also known as: add_method, add_rpc_method
96 97 98 99 100 101 |
# File 'lib/soap/rpc/proxy.rb', line 96 def add_rpc_operation(qname, soapaction, name, param_def, opt = {}) ensure_styleuse_option(opt, :rpc, :encoded) opt[:request_qname] = qname op = Operation.new(soapaction, param_def, opt) assign_operation(name, qname, soapaction, op) end |
#call(name, *params) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/soap/rpc/proxy.rb', line 124 def call(name, *params) # name must be used only for lookup op_info = lookup_operation(name) mapping_opt = create_mapping_opt req_header = create_request_header req_body = SOAPBody.new( op_info.request_body(params, @mapping_registry, @literal_mapping_registry, mapping_opt) ) reqopt = create_encoding_opt( :soapaction => op_info.soapaction || @soapaction, :envelopenamespace => @options["soap.envelope.requestnamespace"], :default_encodingstyle => @default_encodingstyle || op_info.request_default_encodingstyle, :use_default_namespace => op_info.use_default_namespace || @use_default_namespace ) resopt = create_encoding_opt( :envelopenamespace => @options["soap.envelope.responsenamespace"], :default_encodingstyle => @default_encodingstyle || op_info.response_default_encodingstyle ) if reqopt[:generate_explicit_type].nil? reqopt[:generate_explicit_type] = (op_info.request_use == :encoded) end if resopt[:generate_explicit_type].nil? resopt[:generate_explicit_type] = (op_info.response_use == :encoded) end env = route(req_header, req_body, reqopt, resopt, name) if op_info.response_use.nil? return nil end raise EmptyResponseError unless env receive_headers(env.header) begin check_fault(env.body) rescue ::SOAP::FaultError => e op_info.raise_fault(e, @mapping_registry, @literal_mapping_registry) end if @return_response_as_xml resopt[:response_as_xml] else op_info.response_obj(env.body, @mapping_registry, @literal_mapping_registry, mapping_opt) end end |
#check_fault(body) ⇒ Object
206 207 208 209 210 |
# File 'lib/soap/rpc/proxy.rb', line 206 def check_fault(body) if body.fault raise SOAP::FaultError.new(body.fault) end end |
#endpoint_url ⇒ Object
75 76 77 |
# File 'lib/soap/rpc/proxy.rb', line 75 def endpoint_url @endpoint_url end |
#endpoint_url=(endpoint_url) ⇒ Object
79 80 81 82 |
# File 'lib/soap/rpc/proxy.rb', line 79 def endpoint_url=(endpoint_url) @endpoint_url = endpoint_url reset_stream end |
#inspect ⇒ Object
71 72 73 |
# File 'lib/soap/rpc/proxy.rb', line 71 def inspect "#<#{self.class}:#{@endpoint_url}>" end |
#invoke(req_header, req_body, opt = nil) ⇒ Object
114 115 116 117 118 119 120 121 122 |
# File 'lib/soap/rpc/proxy.rb', line 114 def invoke(req_header, req_body, opt = nil) opt ||= create_encoding_opt env = route(req_header, req_body, opt, opt) if @return_response_as_xml opt[:response_as_xml] else env end end |
#reset_stream ⇒ Object
84 85 86 |
# File 'lib/soap/rpc/proxy.rb', line 84 def reset_stream @streamhandler.reset(@endpoint_url) end |
#route(req_header, req_body, reqopt, resopt, method_name = nil) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/soap/rpc/proxy.rb', line 171 def route(req_header, req_body, reqopt, resopt, method_name = nil) req_env = ::SOAP::SOAPEnvelope.new(req_header, req_body) unless reqopt[:envelopenamespace].nil? set_envelopenamespace(req_env, reqopt[:envelopenamespace]) end reqopt[:external_content] = nil conn_data = marshal(req_env, reqopt) if ext = reqopt[:external_content] mime = MIMEMessage.new ext.each do |k, v| mime.(v.data) end mime.add_part(conn_data.send_string + "\r\n") mime.close conn_data.send_string = mime.content_str conn_data.send_contenttype = mime.headers['content-type'].str end conn_data.soapaction = reqopt[:soapaction] start = Time.now begin conn_data = @streamhandler.send(@endpoint_url, conn_data) rescue Exception => e raise # re-raise the exception ensure dauer_ms = (1000 * (Time.now - start)).round http_logger.log(driver_class, method_name, @endpoint_url, conn_data.send_string, conn_data.receive_string, dauer_ms) if http_logger # todo error flag end if conn_data.receive_string.empty? return nil end unmarshal(conn_data, resopt) end |
#set_wiredump_file_base(wiredump_file_base) ⇒ Object
88 89 90 |
# File 'lib/soap/rpc/proxy.rb', line 88 def set_wiredump_file_base(wiredump_file_base) @streamhandler.wiredump_file_base = wiredump_file_base end |
#test_loopback_response ⇒ Object
92 93 94 |
# File 'lib/soap/rpc/proxy.rb', line 92 def test_loopback_response @streamhandler.test_loopback_response end |