Computer Science Canada [Tutorial] XML-RPC Web Service |
Author: | rizzix [ Sun Oct 05, 2003 1:45 pm ] | ||||||||||
Post subject: | [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 website. But i've attached the latest version as of today (Oct 5, 2003). The next question is what is XML? Its a markup language just like HTML. But a lot more versatile. For more information on XML do take a look at w3c website. I won't be saying much on this, since you don't really need to know XML to create an xml-rpc web service. Of course knowledge on xml is helpful. The final question: what is RPC? RPC stands for Remote Procedure Call. Think of it as your application calling a procedure of another application that is located remotely. This is exciting stuff. Since the RPC works by sending XML data instead of bits and bytes, it is highly interoperable, i.e any type of application can call any applications procedures etc. This means that if you write a server that hosts some methods for use in, lets say Perl, a PHP, Java, C/C++, any type of app can call those methods hosted. So lets start... The Server:
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:
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:
To run the Server type this in:
Open another command prompt and type this in to run the Client:
and watch! |
Author: | nasr25 [ Wed Jan 23, 2013 5:22 am ] |
Post subject: | 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 |
Author: | nasr25 [ Wed Jan 23, 2013 5:28 am ] |
Post subject: | 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 |