Hi

This simple Servlet works (address: http://localhost:8080/testapp/testservlet):

public class Server extends HttpServlet {
public void doGet (HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException {
                
PrintWriter out = res.getWriter();
out.println("Hello, you!");
out.close();
}
}

I'm using an ant script that creates testapp.war and deploys it.

my web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
    version="2.4">
  <servlet>
    <servlet-name>TestServlet</servlet-name>
    <servlet-class>testpackage.TestServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>TestServlet</servlet-name>
    <url-pattern>/testservlet</url-pattern>
  </servlet-mapping>
</web-app>

However, my simple Xml Rpc application doesn't. If my client makes a Xml Rpc
call on address http://localhost:8080/testapp/testservlet, I get the error:
Exception in thread "main" java.io.IOException: Server returned HTTP response
code: 500 for URL: http://localhost:8080/testapp/testservlet

Code:

public class Server extends HttpServlet {
        public void doPost (HttpServletRequest req, HttpServletResponse res)
                                        throws ServletException, IOException {
                
                XmlRpcServer xmlrpc = new XmlRpcServer();
                xmlrpc.addHandler ("testHandler", new TestHandler());

                byte[] result = xmlrpc.execute(req.getInputStream());
                res.setContentType("text/xml");
                res.setContentLength(result.length);
                OutputStream out = res.getOutputStream();
                out.write (result);
                out.flush ();
        }
}


public class TestClient {

        public static void main(String[] args) throws XmlRpcException, 
IOException {
                
                
                        XmlRpcClient xmlrpc = new XmlRpcClient
("http://localhost:8080/testapp/testservlet";);
                        Vector params = new Vector ();
                        params.addElement ("hello world");
                        // this method returns a string
                        String result = (String) 
xmlrpc.execute("testHandler.hello", params);
                        System.out.println(result);
                }
}

public class TestHandler implements Serializable {
        public String hello(String input) {
                return input;
        }
}


                
___________________________________________________________ 
How much free photo storage do you get? Store your holiday 
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

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

Reply via email to