
-----------------------------------
rizzix
Sun Oct 05, 2003 1:45 pm

[Tutorial] XML-RPC Web Service
-----------------------------------
What is a web service? Well lets just say it's an emerging new technology. For more information take a look at these articles at: http://webservices.org/index.php/article/articleview/429/1/61/

I'm going to take you through a quick tutorial on a RPC type web service, that runs on the XML-RPC standards. The libraries commonly used for xml-rpc in java is the one provided by Apache.org. You can get more information on the library at their 
//
//  TestServer.java
//

import org.apache.xmlrpc.WebServer;

public class TestServer {
    public String message() {
        return "It Works! Yahooooo!";
    }

    public static void main(String

This is a simple server that uses the http protocol, thus a webserver. 
We create a server object and pass it the port to listen to. Then we register an object with the server with a name. and finally we start the server. In this case we registered the test server object with the server with the name test.


The Client:

//
//  TestClient.java
//

import org.apache.xmlrpc.XmlRpcClient;
import java.util.Vector;

public class TestClient {
    public static void main(String

Here we create an XmlRpcClient object. The client object represents a connection to the server. We call the execute method passing the method to call, and a Vector of arguments to pass to the method. If there are not arguments to pass, send in an empty vector object. The execute method has a return type of Object, so you will have to cast the object to String after all the message method of the TestServer object (which was registered as 'test') returns a String object. Then the rest is quite obvious.

Try it out... 

before compilation make sure the two xml-rpc jar files are in the same directory as the java files you've written.

to compile open the command prompt and type this in:
javac -classpath xmlrpc-1.2-b1.jar Test*.java

To run the Server type this in:
java -classpath xmlrpc-1.2-b1.jar;. TestServer

Open another command prompt and type this in to run the Client:
java -classpath xmlrpc-1.2-b1.jar;. TestClient

and watch!

-----------------------------------
nasr25
Wed Jan 23, 2013 5:22 am

RE:[Tutorial] XML-RPC Web Service
-----------------------------------
very thank for that

i was search abouy xml rpc from a month

thanks and have a nice work

-----------------------------------
nasr25
Wed Jan 23, 2013 5:28 am

RE:[Tutorial] XML-RPC Web Service
-----------------------------------
very thank for that

i was search abouy xml rpc from a month

thanks and have a nice work
