I'm using:

xmlrpc-current.zip            25-May-2005 14:54   752k  Apache XMLRPC
downloads

The specific jar is:

xmlrpc-2.0.jar

I start the WebServer with the command:

java org.apache.xmlrpc.WebServer

Then I run a client to connect using basic authentication. Here is the
client code:

import java.util.*;
import org.apache.xmlrpc.*;

public class MyTestClient {
    /**
     * Just for testing.
     */
    public static void main(String args[]) throws Exception {
         try {
                String url = "http://localhost:8080";;
            String method = "auth.test";
            Vector v = new Vector();
                v.addElement("Just testing");
                v.addElement(new Integer(123));
                
            XmlRpcClient client = new XmlRpcClient(url);
            client.setBasicAuthentication("someuser","somepasswd");
                System.out.println(client.execute(method, v));
                
        } catch(Exception e){
            e.printStackTrace();
        }
    }
}

Authentication fails with this message:

org.apache.xmlrpc.XmlRpcException: org.apache.xmlrpc.XmlRpcException: Sorry,
you're not allowed in here!

The body of 'auth' is:

package org.apache.xmlrpc;

import java.util.Vector;

/**
 *
 * @author <a href="mailto:[EMAIL PROTECTED]">Hannes Wallnoefer</a>
 * @version $Id: AuthDemo.java,v 1.3 2005/04/22 10:25:57 hgomez Exp $
 */
public class AuthDemo implements AuthenticatedXmlRpcHandler
{
    /**
     *
     */
    public Object execute(String method, Vector v, String user, String
password)
            throws Exception
    {
        // our simplistic authentication guidelines never fail ;)
        if (user == null || user.startsWith("bad"))
        {
            throw new XmlRpcException(5, "Sorry, you're not allowed in
here!");
        }

        return ("Hello " + user);
    }
}


So what gives? Why the failure?

Terrance

Reply via email to