You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@ws.apache.org by "Daly, Louis" <da...@u.library.arizona.edu> on 2002/04/03 00:22:55 UTC
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;
}
}