Hello list,

The FAQ as currently hosted at http://ws.apache.org/xmlrpc/faq.html 
has an incorrect answer for server question 4: "How to I get the clients IP 
address in a handler?" with respect to WS-XMLRPC 3.1.

The recommended solution is to override newPropertyHandlerMapping() in
XmlRpcServlet-derived subclasses, as follows:

protected PropertyHandlerMapping newPropertyHandlerMapping(URL url) 
  throws IOException, XmlRpcException 
{
  PropertyHandlerMapping mapping = super.newPropertyHandlerMapping(url);
  RequestProcessorFactoryFactory factory = 
    new RequestSpecificProcessorFactoryFactory() {
      protected Object getRequestProcessor(Class pClass, 
        XmlRpcRequest pRequest) throws XmlRpcException 
      {
        RequestInitializableRequestProcessor proc =
          (RequestInitializableRequestProcessor) 
           super.getRequestProcessor(pClass, pRequest);
        proc.init((MyConfig) pRequest.getConfig());
        return proc;
      }
    };
  mapping.setRequestProcessorFactoryFactory(factory);
  return mapping;
}

However, this does not work because (as I found out after several hours' worth 
of digging through the code) the reflexive handler mapping is established 
during the call to super.newPropertyHandlerMapping(), when the new factory is 
not yet set up.

The solution is to re-establish the mappings after setting up the custom
request processor factory factory, by adding the following before
the return statement:

  mapping.load(Thread.currentThread().getContextClassLoader(), url);

I would be grateful if the FAQ gets updated, so that other people can
avoid the confusion I'd stumbled over.

Sincerely,
-- 
Daniel Janus <[EMAIL PROTECTED]>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to