Class SOAP::RPC::SOAPlet
In: soap/rpc/soaplet.rb
Parent: WEBrick::HTTPServlet::AbstractServlet

Methods

Classes and Modules

Class SOAP::RPC::SOAPlet::RequestRouter

Attributes

app_scope_router  [R] 

Public Class methods

[Source]

# File soap/rpc/soaplet.rb, line 187
    def add_servant_method_to_router(router, obj, namespace, name)
      qname = XSD::QName.new(namespace, name)
      soapaction = nil
      method = obj.method(name)
      param_def = ::SOAP::RPC::SOAPMethod.create_param_def(
        (1..method.arity.abs).collect { |i| "p#{ i }" })
      router.add_method(obj, qname, soapaction, name, param_def)
    end

[Source]

# File soap/rpc/soaplet.rb, line 177
    def add_servant_to_router(router, obj, namespace)
      ::SOAP::RPC.defined_methods(obj).each do |name|
        begin
          add_servant_method_to_router(router, obj, namespace, name)
        rescue SOAP::RPC::MethodDefinitionError => e
          p e if $DEBUG
        end
      end
    end

[Source]

# File soap/rpc/soaplet.rb, line 22
  def initialize
    @router_map = {}
    @app_scope_router = ::SOAP::RPC::Router.new(self.class.name)
    @headerhandlerfactory = []
    @app_scope_headerhandler = nil
  end

Public Instance methods

add_headerhandler(obj)

[Source]

# File soap/rpc/soaplet.rb, line 64
  def add_rpc_headerhandler(obj)
    @app_scope_headerhandler = obj
  end

[Source]

# File soap/rpc/soaplet.rb, line 57
  def add_rpc_request_headerhandler(factory)
    unless factory.respond_to?(:create)
      raise TypeError.new("factory must respond to 'create'")
    end
    @headerhandlerfactory << factory
  end

Add servant factory whose object has request scope. A servant object is instanciated for each request.

Bear in mind that servant factories are distinguished by HTTP SOAPAction header in request. Client which calls request-scoped servant must have a SOAPAction header which is a namespace of the servant factory. I mean, use Driver#add_method_with_soapaction instead of Driver#add_method at client side.

A factory must respond to :create.

[Source]

# File soap/rpc/soaplet.rb, line 40
  def add_rpc_request_servant(factory, namespace, mapping_registry = nil)
    unless factory.respond_to?(:create)
      raise TypeError.new("factory must respond to 'create'")
    end
    router = setup_request_router(namespace)
    router.factory = factory
    router.mapping_registry = mapping_registry
  end

Add servant object which has application scope.

[Source]

# File soap/rpc/soaplet.rb, line 50
  def add_rpc_servant(obj, namespace)
    router = @app_scope_router
    SOAPlet.add_servant_to_router(router, obj, namespace)
    add_router(namespace, router)
  end
add_servant(obj, namespace)

Alias for add_rpc_servant

[Source]

# File soap/rpc/soaplet.rb, line 81
  def do_GET(req, res)
    res.header['Allow'] = 'POST'
    raise WEBrick::HTTPStatus::MethodNotAllowed, "GET request not allowed."
  end

[Source]

# File soap/rpc/soaplet.rb, line 86
  def do_POST(req, res)
    namespace = parse_soapaction(req.meta_vars['HTTP_SOAPACTION'])
    router = lookup_router(namespace)
    with_headerhandler(router) do |router|
      begin
        conn_data = ::SOAP::StreamHandler::ConnectionData.new
        conn_data.receive_string = req.body
        conn_data.receive_contenttype = req['content-type']
        conn_data = router.route(conn_data)
        if conn_data.is_fault
          res.status = WEBrick::HTTPStatus::RC_INTERNAL_SERVER_ERROR
        end
        res.body = conn_data.send_string
        res['content-type'] = conn_data.send_contenttype
      rescue Exception => e
        conn_data = router.create_fault_response(e)
        res.status = WEBrick::HTTPStatus::RC_INTERNAL_SERVER_ERROR
        res.body = conn_data.send_string
        res['content-type'] = conn_data.send_contenttype || "text/xml"
      end
    end

    if res.body.is_a?(IO)
      res.chunked = true
    end
  end

Servlet interfaces for WEBrick.

[Source]

# File soap/rpc/soaplet.rb, line 72
  def get_instance(config, *options)
    @config = config
    self
  end

[Source]

# File soap/rpc/soaplet.rb, line 77
  def require_path_info?
    false
  end

[Validate]