Results 1 to 2 of 2
  1. #1
    ypktm is offline Member
    Join Date
    Nov 2010
    Rep Power

    Default Extracing xml rpc Servlet Request parameters

    I am using apache XML-RPC libraries for client-server communication with tomcat as the servlet. I am trying to find out the best option for extracting request parameters inside a servlet.

    Here is the code snippet:

    public class PGXMLRPCServer extends XmlRpcServlet {

    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    // need a way to extract the XML body here


    I could use XML parsers like SAX, JAXP, etc. for parsing the request to find out the incoming parameters. But I thought that there has to be some easier way of retrieving the parameters, since the base XmlRpcServlet classes or its superclasses should have already implemented these methods that I am not aware of.
    My incoming request looks like this:

    POST /xmlrpc HTTP/1.1
    Content-Type: text/xml
    User-Agent: Apache XML RPC 3.1.3 (Sun HTTP Transport)
    Content-Length: 200
    Cache-Control: no-cache
    Pragma: no-cache
    Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Connection: keep-alive

    <?xml version="1.0" encoding="UTF-8"?><methodCall><methodName>Calculator.add</methodName><params><param><value><i4>33</i4></value></param><param><value><i4>9</i4></value></param></params></methodCall>

    I need to know the following information:

    1) method name: Calculator.add
    2) List of parameters: 33 and 9

    What would be the easiest way of accomplishing this? Thanks for your help in advance.

  2. #2
    FON is offline Senior Member
    Join Date
    Dec 2009
    Belgrade, Serbia
    Rep Power


    Not familiar with this but have found this in javadoc:

    1) method name: Calculator.add
    Java Code:
    Class RequestData
    public java.lang.String getMethod()
        Returns the request method.
            The request method, should be "POST".
    2) List of parameters: 33 and 9
    Java Code:
    Class HttpServletRequestImpl
    Stub implementation of a HttpServletRequest with lots of unimplemented methods.
    so i guess you would have to implement methods that work with params and values like:

    Java Code:
    java.util.Enumeration 	getParameterNames()
     java.lang.String[] 	getParameterValues(java.lang.String pName)
    hope this can help, but honestly i think it's not so big deal if you work with those parsers because

    In XML-RPC Specification :

    The payload is in XML, a single <methodCall> structure.

Similar Threads

  1. Passing Parameters to servlet
    By praveen_1987 in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 06-30-2010, 12:30 PM
  2. How to set request parameters to an URLConnection
    By somesh A in forum Networking
    Replies: 0
    Last Post: 04-10-2009, 09:08 AM
  3. Dispatching request to another Servlet
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-27-2008, 09:20 PM
  4. Replies: 0
    Last Post: 01-27-2008, 09:17 PM
  5. Servlet that receive n parameters
    By Felissa in forum Java Servlet
    Replies: 1
    Last Post: 06-07-2007, 08:22 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts