Uploaded image for project: 'XML-RPC'
  1. XML-RPC
  2. XMLRPC-147

Capturing the client's IP address in a handler does not work as advertised



    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1
    • Fix Version/s: 3.1.1
    • Component/s: Source
    • Labels:
    • Environment:
      JDK 1.5.0_11 powered by Kubuntu 7.04 on an i686


      Below is a verbatim copy of an email I've sent to the xmlrpc-dev mailing 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; }

      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.

      — end of mail —

      However, it is uncertain whether it is actually a bug in the FAQ or elsewhere.




            • Assignee:
              jochen@apache.org Jochen Wiedmann
              nathell Daniel Janus
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: