Class: SOAP::RPC::Router
- Includes:
- SOAP
- Defined in:
- lib/action_web_service/soap/rpc/router.rb
Defined Under Namespace
Classes: ApplicationScopeOperation, Operation, RequestScopeOperation
Constant Summary
Constants included from SOAP
AttrActor, AttrArrayType, AttrArrayTypeName, AttrEncodingStyle, AttrEncodingStyleName, 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, TypeMap, VERSION, ValueArray, ValueArrayName, XSDNamespaceTag, XSINamespaceTag
Instance Attribute Summary collapse
-
#actor ⇒ Object
readonly
Returns the value of attribute actor.
-
#external_ces ⇒ Object
Returns the value of attribute external_ces.
-
#generate_explicit_type ⇒ Object
Returns the value of attribute generate_explicit_type.
-
#literal_mapping_registry ⇒ Object
Returns the value of attribute literal_mapping_registry.
-
#mapping_registry ⇒ Object
Returns the value of attribute mapping_registry.
Instance Method Summary collapse
- #add_document_operation(receiver, soapaction, name, param_def, opt = {}) ⇒ Object (also: #add_document_method)
- #add_document_request_operation(factory, soapaction, name, param_def, opt = {}) ⇒ Object
- #add_headerhandler(handler) ⇒ Object
-
#add_request_headerhandler(factory) ⇒ Object
header handler interface.
-
#add_rpc_operation(receiver, qname, soapaction, name, param_def, opt = {}) ⇒ Object
(also: #add_method, #add_rpc_method)
operation definition interface.
- #add_rpc_request_operation(factory, qname, soapaction, name, param_def, opt = {}) ⇒ Object
-
#add_rpc_request_servant(factory, namespace) ⇒ Object
servant definition interface.
- #add_rpc_servant(obj, namespace) ⇒ Object (also: #add_servant)
-
#create_fault_response(e) ⇒ Object
Create fault response string.
-
#initialize(actor) ⇒ Router
constructor
A new instance of Router.
- #route(conn_data) ⇒ Object
Constructor Details
#initialize(actor) ⇒ Router
Returns a new instance of Router.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/action_web_service/soap/rpc/router.rb', line 33 def initialize(actor) @actor = actor @mapping_registry = nil @headerhandler = Header::HandlerSet.new @literal_mapping_registry = ::SOAP::Mapping::WSDLLiteralRegistry.new @generate_explicit_type = true @external_ces = nil @operation_by_soapaction = {} @operation_by_qname = {} @headerhandlerfactory = [] end |
Instance Attribute Details
#actor ⇒ Object (readonly)
Returns the value of attribute actor.
27 28 29 |
# File 'lib/action_web_service/soap/rpc/router.rb', line 27 def actor @actor end |
#external_ces ⇒ Object
Returns the value of attribute external_ces.
31 32 33 |
# File 'lib/action_web_service/soap/rpc/router.rb', line 31 def external_ces @external_ces end |
#generate_explicit_type ⇒ Object
Returns the value of attribute generate_explicit_type.
30 31 32 |
# File 'lib/action_web_service/soap/rpc/router.rb', line 30 def generate_explicit_type @generate_explicit_type end |
#literal_mapping_registry ⇒ Object
Returns the value of attribute literal_mapping_registry.
29 30 31 |
# File 'lib/action_web_service/soap/rpc/router.rb', line 29 def literal_mapping_registry @literal_mapping_registry end |
#mapping_registry ⇒ Object
Returns the value of attribute mapping_registry.
28 29 30 |
# File 'lib/action_web_service/soap/rpc/router.rb', line 28 def mapping_registry @mapping_registry end |
Instance Method Details
#add_document_operation(receiver, soapaction, name, param_def, opt = {}) ⇒ Object Also known as: add_document_method
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/action_web_service/soap/rpc/router.rb', line 119 def add_document_operation(receiver, soapaction, name, param_def, opt = {}) # # adopt workaround for doc/lit wrapper method # (you should consider to simply use rpc/lit service) # #unless soapaction # raise RPCRoutingError.new("soapaction is a must for document method") #end ensure_styleuse_option(opt, :document, :literal) op = ApplicationScopeOperation.new(soapaction, receiver, name, param_def, opt) if opt[:request_style] != :document raise RPCRoutingError.new("illegal request_style given") end assign_operation(soapaction, first_input_part_qname(param_def), op) end |
#add_document_request_operation(factory, soapaction, name, param_def, opt = {}) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/action_web_service/soap/rpc/router.rb', line 137 def add_document_request_operation(factory, soapaction, name, param_def, opt = {}) # # adopt workaround for doc/lit wrapper method # (you should consider to simply use rpc/lit service) # #unless soapaction # raise RPCRoutingError.new("soapaction is a must for document method") #end ensure_styleuse_option(opt, :document, :literal) op = RequestScopeOperation.new(soapaction, receiver, name, param_def, opt) if opt[:request_style] != :document raise RPCRoutingError.new("illegal request_style given") end assign_operation(soapaction, first_input_part_qname(param_def), op) end |
#add_headerhandler(handler) ⇒ Object
55 56 57 |
# File 'lib/action_web_service/soap/rpc/router.rb', line 55 def add_headerhandler(handler) @headerhandler.add(handler) end |
#add_request_headerhandler(factory) ⇒ Object
header handler interface
48 49 50 51 52 53 |
# File 'lib/action_web_service/soap/rpc/router.rb', line 48 def add_request_headerhandler(factory) unless factory.respond_to?(:create) raise TypeError.new("factory must respond to 'create'") end @headerhandlerfactory << factory end |
#add_rpc_operation(receiver, qname, soapaction, name, param_def, opt = {}) ⇒ Object Also known as: add_method, add_rpc_method
operation definition interface
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/action_web_service/soap/rpc/router.rb', line 96 def add_rpc_operation(receiver, qname, soapaction, name, param_def, opt = {}) ensure_styleuse_option(opt, :rpc, :encoded) opt[:request_qname] = qname op = ApplicationScopeOperation.new(soapaction, receiver, name, param_def, opt) if opt[:request_style] != :rpc raise RPCRoutingError.new("illegal request_style given") end assign_operation(soapaction, qname, op) end |
#add_rpc_request_operation(factory, qname, soapaction, name, param_def, opt = {}) ⇒ Object
109 110 111 112 113 114 115 116 117 |
# File 'lib/action_web_service/soap/rpc/router.rb', line 109 def add_rpc_request_operation(factory, qname, soapaction, name, param_def, opt = {}) ensure_styleuse_option(opt, :rpc, :encoded) opt[:request_qname] = qname op = RequestScopeOperation.new(soapaction, factory, name, param_def, opt) if opt[:request_style] != :rpc raise RPCRoutingError.new("illegal request_style given") end assign_operation(soapaction, qname, op) end |
#add_rpc_request_servant(factory, namespace) ⇒ Object
servant definition interface
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/action_web_service/soap/rpc/router.rb', line 62 def add_rpc_request_servant(factory, namespace) unless factory.respond_to?(:create) raise TypeError.new("factory must respond to 'create'") end obj = factory.create # a dummy instance for introspection ::SOAP::RPC.defined_methods(obj).each do |name| begin qname = XSD::QName.new(namespace, name) param_def = ::SOAP::RPC::SOAPMethod.derive_rpc_param_def(obj, name) opt = create_styleuse_option(:rpc, :encoded) add_rpc_request_operation(factory, qname, nil, name, param_def, opt) rescue SOAP::RPC::MethodDefinitionError => e p e if $DEBUG end end end |
#add_rpc_servant(obj, namespace) ⇒ Object Also known as: add_servant
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/action_web_service/soap/rpc/router.rb', line 79 def add_rpc_servant(obj, namespace) ::SOAP::RPC.defined_methods(obj).each do |name| begin qname = XSD::QName.new(namespace, name) param_def = ::SOAP::RPC::SOAPMethod.derive_rpc_param_def(obj, name) opt = create_styleuse_option(:rpc, :encoded) add_rpc_operation(obj, qname, nil, name, param_def, opt) rescue SOAP::RPC::MethodDefinitionError => e p e if $DEBUG end end end |
#create_fault_response(e) ⇒ Object
Create fault response string.
183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/action_web_service/soap/rpc/router.rb', line 183 def create_fault_response(e) env = SOAPEnvelope.new(SOAPHeader.new, SOAPBody.new(fault(e))) opt = {} opt[:external_content] = nil response_string = Processor.marshal(env, opt) conn_data = StreamHandler::ConnectionData.new(response_string) conn_data.is_fault = true if ext = opt[:external_content] mimeize(conn_data, ext) end conn_data end |
#route(conn_data) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/action_web_service/soap/rpc/router.rb', line 153 def route(conn_data) # we cannot set request_default_encodingsyle before parsing the content. env = unmarshal(conn_data) if env.nil? raise ArgumentError.new("illegal SOAP marshal format") end op = lookup_operation(conn_data.soapaction, env.body) headerhandler = @headerhandler.dup @headerhandlerfactory.each do |f| headerhandler.add(f.create) end receive_headers(headerhandler, env.header) soap_response = default_encodingstyle = nil begin soap_response = op.call(env.body, @mapping_registry, @literal_mapping_registry, create_mapping_opt) default_encodingstyle = op.response_default_encodingstyle rescue Exception soap_response = fault($!) default_encodingstyle = nil end conn_data.is_fault = true if soap_response.is_a?(SOAPFault) header = call_headers(headerhandler) body = SOAPBody.new(soap_response) env = SOAPEnvelope.new(header, body) marshal(conn_data, env, default_encodingstyle) end |