Method: SOAP::RPC::Router#route

Defined in:
lib/soap/rpc/router.rb

#route(conn_data) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
169
170
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
# File 'lib/soap/rpc/router.rb', line 157

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
  soap_response = default_encodingstyle = nil
  begin
    receive_headers(headerhandler, env.header)
    soap_response =
      op.call(env.body, @mapping_registry, @literal_mapping_registry,
        create_mapping_opt)
    conn_data.is_fault = true if soap_response.is_a?(SOAPFault)
    default_encodingstyle = op.response_default_encodingstyle
  rescue Exception => e
    # If a wsdl fault was raised by service, the fault declaration details
    # is kept in wsdl_fault. Otherwise (exception is a program fault)
    # wsdl_fault is nil
    wsdl_fault_details = op.faults && op.faults[e.class.name]
    soap_response = fault(e, wsdl_fault_details)
    conn_data.is_fault = true
    default_encodingstyle = nil
  end
  header = call_headers(headerhandler)
  if op.response_use.nil?
    conn_data.send_string = ''
    conn_data.is_nocontent = true
    conn_data
  else
    body = SOAPBody.new(soap_response, conn_data.is_fault)
    env = SOAPEnvelope.new(header, body)
    marshal(conn_data, env, default_encodingstyle)
  end
end