Results 1 to 3 of 3
  1. #1
    BigBear is offline Member
    Join Date
    Jan 2010
    Rep Power

    Default xmlrpc returns unexpected status

    Hi all I'm trying to use xmlrpc server, because of downloading data from web url to desktop (swing) application. I found XML-RPC and it seems to be great for my purpose. But when I'm trying to connect to xmlrpc, server returns following:
    Java Code:
    org.apache.xmlrpc.client.XmlRpcHttpTransportException: HTTP server returned unexpected status: Not Found
            at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(
            at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(
            at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(
            at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(
            at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(
            at org.apache.xmlrpc.client.XmlRpcClient.execute(
            at org.apache.xmlrpc.client.XmlRpcClient.execute(
            at org.apache.xmlrpc.client.XmlRpcClient.execute(
    I followed manual for The XML-RPC Servlet and I wrote these lines into my web.xml
    Java Code:
    <web-app version="2.4"
    			<description>Sets, whether the servlet supports vendor extensions for XML-RPC.</description>
    my servlet looks like this:
    Java Code:
    package services;
    import org.apache.xmlrpc.*;
    import org.apache.xmlrpc.common.*;
    import org.apache.xmlrpc.server.*;
    import org.apache.xmlrpc.webserver.*;
    public class EOTService extends XmlRpcServlet {
    	private boolean isAuthenticated(String pUserName, String pPassword) {
    		return pUserName.equals("username") && pPassword.equals("password");
    	protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException {
    		PropertyHandlerMapping mapping = (PropertyHandlerMapping) super.newXmlRpcHandlerMapping();
    		AbstractReflectiveHandlerMapping.AuthenticationHandler handler =
    			new AbstractReflectiveHandlerMapping.AuthenticationHandler() {
    				public boolean isAuthorized(XmlRpcRequest pRequest) {
    					XmlRpcHttpRequestConfig config = (XmlRpcHttpRequestConfig) pRequest.getConfig();
    					return isAuthenticated(config.getBasicUserName(), config.getBasicPassword());
    		try {
    			mapping.addHandler("Calculator", Class.forName("services.Calculator"));
    		} catch (ClassNotFoundException e) {
    		return mapping;
    (instead of I added handler - I read that this method is fine - but I tried to create too and it's not working)...
    and in the same package I have the class Calculator
    Java Code:
    package services;
    public class Calculator {
    	public int add(int a, int b) {
    		return a + b;
    	public int sub(int a, int b) {
    		return a - b;
    My client is simple, but in accordance with manual
    Java Code:
    try {
                XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
                config.setServerURL(new URL(""));
                XmlRpcClient client = new XmlRpcClient();
                Object[] params = new Object[]{new Integer(33), new Integer(9)};
                Integer result = (Integer)client.execute("Calculator.add", params);
                System.out.println("33 + 9 = " + result);
            } catch ( e) {
                System.out.println("MalformedURLException: " + e.getMessage());
            } catch (org.apache.xmlrpc.XmlRpcException e) {
    When I put http://localhost:8080/eot/service in my browser, it returns exception:
    Java Code:
    HTTP method GET is not supported by this URL
    but it should return this exception, so I think that it works ok.
    Does somebody know, where the problem is? Thank you.

  2. #2
    mangstadt is offline Member
    Join Date
    Jul 2010
    Rep Power


    Look at the servlet URL in your client code...

    Quote Originally Posted by BigBear View Post
    Java Code:
    config.setServerURL(new URL(""));

  3. #3
    BigBear is offline Member
    Join Date
    Jan 2010
    Rep Power

Similar Threads

  1. Error: unexpected type
    By silvia in forum New To Java
    Replies: 3
    Last Post: 02-05-2010, 10:54 PM
  2. Unexpected characters using PrintWriter
    By mjwoodford in forum New To Java
    Replies: 1
    Last Post: 09-18-2009, 07:09 PM
  3. unexpected type
    By one in forum New To Java
    Replies: 13
    Last Post: 01-20-2009, 10:32 AM
  4. Unexpected Error
    By Mir in forum New To Java
    Replies: 10
    Last Post: 07-07-2008, 08:57 PM
  5. An unexpected jumper bug on my IO code?
    By cruxblack in forum New To Java
    Replies: 7
    Last Post: 07-29-2007, 09:24 AM

Posting Permissions

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