Well - I took stab at this and I'm not sure what level of java experience you have but there are some things I had to do to get this working. Let me state that this is my first attempt at XML-RPC in any language!

This is my java class file:
import org.apache.xmlrpc.XmlRpcClient;
import org.apache.xmlrpc.XmlRpcException;
import java.util.Vector;
import java.net.MalformedURLException;
import java.io.IOException;

public class RPCTest {
public RPCTest() {
System.out.println("Constructor called");
}

static void main(String args[]) {
try {
XmlRpcClient xmlrpc = new XmlRpcClient("http://localhost/WKMod/Examples/XMLRPCExample";);
Vector params = new Vector();
params.addElement("10");
params.addElement("20");
Object result = xmlrpc.execute("multiply", params);
System.out.println(result);
} catch (XmlRpcException e) {
System.out.println(e);
} catch (MalformedURLException e) {
System.out.println(e);
} catch (IOException e) {
System.out.println(e);
}
}
}

I also had to modify the XMLRPCExample.py example to convert the numbers to strings. Also the java method xmlrpc.execute() returned an Integer object (not an int) so the example on xml.apache.org gave me a ClassCastException.
I don't know any of the intricacies or conventions surrounding XML-RPC so you may want to read up on that a bit but using the XMLRPC example with the minor changes here worked fine (remember to put your URL in there as I was using mod_webkit and it seemed you were using a CGI)

added casts to int in XMLRPCExample.py because the java Vector class only excepts Objects (like String's) and not primitivess

def multiply(self, x, y):
return int(x) * int(y)

def add(self, x, y):
return int(x) + int(y)

mike

On Wednesday, January 15, 2003, at 02:43 PM, Randy Heiland wrote:

First, thanks to those who responded, primarily with pointers to
http://xml.apache.org/xmlrpc/ . I installed that pkg and saw the sample
client, however, I still need some handholding.

First, let me be clear, I want to connect to the WebKit/AppServer Python server
from a Java client. Can someone tell me what the params to XmlRpcClient would
be? E.g., should hostName =
"http://myhost/cgi-bin/WebKit.cgi/Examples/XMLRPCExample";

What about SERVER_PORT?

client = new XmlRpcClient(hostName, SERVER_PORT);


thanks,
--Randy


-------------------------------------------------------
This SF.NET email is sponsored by: A Thawte Code Signing Certificate is essential in establishing user confidence by providing assurance of authenticity and code integrity. Download our Free Code Signing guide:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0028en
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to