WebService XML-RPC session access?

Is there a way to provide access to the session[] from an XML-RPC

I am currently writing an XML-RPC server in Rails, and am using layered
dispatching. Unfortunately, everything works great except session is
always null in the ActionWebService controllers.

Is it possible to get session[] working with layered dispatch in


In case anyone else spends a WEEK trying to get XML-RPC sessions
working like I did.

I combined another post in this Google group about HTTP authentication
with my approach. This uses 401 Basic authentication, and returns a
session_id which can be passed as a Cookie in subsequent requests. Not
completely XMLRPC stds-compliant, but works for Rails/Perl/Java.

The missing link was I have to call new(session) in my layered

class RpcController < ApplicationController
wsdl_service_name ‘RPC’
web_service_dispatching_mode :layered

 # Must use the {BLOCK} mode of layered dispatch, and explicitly
 # pass the session ID into the new() method
 web_service(:auth) { AuthService.new(session) }


Then, in apis/auth_service.rb:

class AuthService < XmlRpcService
web_service_api AuthAPI
# methods here…

And finally, my base XMLRPC ActionWebService class,

class XmlRpcService < ApplicationController
def initialize(session)
logger.debug “new=#{session}”
@session = session

I setup all my layered WebService classes to inherit from this.

Just had to find the right combination of black magic…