You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rpc-user@xml.apache.org by John Twomey <jt...@ghsinc.com> on 2002/04/03 15:03:07 UTC

RE: servlet

Hi Louis,
 
Using a standard HTTP POST does not seem to work since the post method
will URLencode(or something - its early) the XML-RPC call. The Post
includes headers etc. and some charactors are encoded - XML RPC only
wants the call as you have it in your post box. This can be confirmed by
the fact that you recieved an answer from your "LiteClient" - so your
servlet works!!!
The answer probably lies in using the XML-RPC applet to make the call
and probably process the return.
 
Thats My take on it anyway - others may have more to add or take away. 
If someone has an answer to making an HTTP POST work I would love to
know it. 
 
 
Take care,
 
John 

	-----Original Message----- 
	From: Daly, Louis 
	Sent: Tue 4/2/2002 5:22 PM 
	To: 'rpc-user@xml.apache.org' 
	Cc: 
	Subject: servlet 
	
	


	I really need to get one basic thing going so I can start to
figure out
	stuff
	
	This form calls my servlet
	http://lou.library.arizona.edu/testmail.html
	myservlet is below (tries to call Echo)
	
	I know the server is running as I started it like so
	
	C:\>java org.apache.xmlrpc.WebServer 9000
	And this works
	C:\tom4\webapps\examples\WEB-INF\classes\org\apache\xmlrpc>
	c:\java14\bin\java org.apache.xmlrpc.XmlRpcClientLite
	http://lou.library.arizona.edu:9000 echo test 123
	        [test, 123]
	
	help!
	lou
	
	
	
//??????????????????????????????????????????????????????????????????
	// Copyright 1999 Hannes Wallnöfer, Raphael Spannocchi
	
	package org.apache.xmlrpc;
	
	import javax.servlet.*;
	import javax.servlet.http.*;
	import java.io.*;
	import java.util.Vector;
	
	public class XmlRpcServlet extends HttpServlet implements
XmlRpcHandler {
	
	    public XmlRpcServer xmlrpc;
	
	        xmlrpc = new XmlRpcServer ();
	
	    public void init (ServletConfig config) throws
ServletException
	    {
	        if ("true".equalsIgnoreCase (config.getInitParameter
("debug")))
	            XmlRpc.setDebug (true);
	        String url = config.getInitParameter ("url");
	        xmlrpc = new XmlRpcServer ();
	        try
	        {
	            xmlrpc.addHandler ("$default", new XmlRpcClientLite
(url));
	        }
	        catch (Exception x)
	        {
	            throw new ServletException ("Invalid URL: "+url + "
("+
	                    x.toString () + ")");
	        }
	    }
	
	
	        try
	        {
	            xmlrpc.addHandler ("$default", new XmlRpcClientLite
());
	        }
	        catch (Exception x)
	        {
	            throw new ServletException ("Invalid URL: "+url + "
("+
	                    x.toString () + ")");
	        }
	    }
	
	
	
	    public void doPost(HttpServletRequest req,
HttpServletResponse res)
	                throws ServletException, IOException  {
	        byte[] result = xmlrpc.execute (req.getInputStream ());
	        res.setContentType("text/xml");
	        res.setContentLength (result.length);
	        OutputStream output = res.getOutputStream();
	        output.write (result);
	        output.flush ();
	    }
	
	    /**
	     * Callback method for XML-RPC server
	     */
	    public Object execute (String methodname, Vector params) {
	        return params;
	    }
	
	}