Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » XML-RPC (Novice)
XML-RPC (Novice) [message #489376] Fri, 02 October 2009 16:31 Go to next message
Jones  is currently offline Jones Friend
Messages: 3
Registered: October 2009
Junior Member
I created a client as shown here http://ws.apache.org/xmlrpc/client.html by creating a new Java project and just adding a class and pasting the code in that class.

I have been trying to follow the instructions listed athttp://ws.apache.org/xmlrpc/server.html for two days. I have created a Java Web App. I then create a servlet and added the following code.
Code:
package org.apache.xmlrpc.demo;
    public class Calculator {
                public int add(int i1, int i2) {
                        return i1 + i2;
                }
                public int subtract(int i1, int i2) {
                        return i1 - i2;
                }
    }


I then create the property as stated in step 2. I named my package server and I placed the property file in it. I do not understand how to place it in my jar file. Which jar file are they talking? Do I create a new jar file?
In step 3 I just copied and paste the XML file in web.xml.
Could someone please explain in a little more detail how this is done especially steps 2 and 3. Thanks.
Re: XML-RPC (Novice) [message #489386 is a reply to message #489376] Fri, 02 October 2009 18:07 Go to previous messageGo to next message
Mark Hutchinson is currently offline Mark HutchinsonFriend
Messages: 53
Registered: July 2009
Member
Hi Jones,

WTP provides web service wizards that make creating axis web services
and clients easy.

If all you want to do is get a web service and a client talking to each
other then I suggest that you try out the web services wizards. You can
create a service "Top down" (from a WSDL file), or "bottom up" from a
java implementation. We have some tutorials on the wiki that show how
to do this:

top down:
http://wiki.eclipse.org/Creating_a_Top-Down_Java_Web_Service _Skeleton_from_a_WSDL_Document


bottom up:
http://wiki.eclipse.org/Creating_a_Bottom-Up_Java_Web_Servic e

Once you have created your service you can create a client for it by
following this tutorial:
http://wiki.eclipse.org/Creating_a_Java_Web_Service_Client

These wizards should hopefully get your web service running up in
minutes, rather than days :)


Jones wrote:
> I created a client as shown here http://ws.apache.org/xmlrpc/client.html
> by creating a new Java project and just adding a class and pasting the
> code in that class.
>
> I have been trying to follow the instructions listed
> athttp://ws.apache.org/xmlrpc/server.html for two days. I have created a
> Java Web App. I then create a servlet and added the following code.
> Code:
> package org.apache.xmlrpc.demo;
> public class Calculator {
> public int add(int i1, int i2) {
> return i1 + i2;
> }
> public int subtract(int i1, int i2) {
> return i1 - i2;
> }
> }
>
> I then create the property as stated in step 2. I named my package
> server and I placed the property file in it. I do not understand how to
> place it in my jar file. Which jar file are they talking? Do I create a
> new jar file?
> In step 3 I just copied and paste the XML file in web.xml.
> Could someone please explain in a little more detail how this is done
> especially steps 2 and 3. Thanks.
Re: XML-RPC (Novice) [message #489400 is a reply to message #489386] Fri, 02 October 2009 19:26 Go to previous messageGo to next message
Jones  is currently offline Jones Friend
Messages: 3
Registered: October 2009
Junior Member
Thanks. I hope be up an running in minutes Razz
Re: XML-RPC (Novice) [message #493619 is a reply to message #489386] Tue, 27 October 2009 09:23 Go to previous messageGo to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 2
Registered: October 2009
Junior Member
It seems this is just SOAP, no XML RPC (which is what he was asking for).

I am looking for the same thing: XML RPC service that lives in a standard HTTPServlet which can run in any app server (tomcat or other).
Re: XML-RPC (Novice) [message #493967 is a reply to message #489376] Wed, 28 October 2009 15:53 Go to previous messageGo to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 2
Registered: October 2009
Junior Member
The steps as described on the xml rpc page are not very extensive.

What you need to do is essentially:
1. create a new Dynamic Web Project in Eclipse, and generate a dummy class that is a subclass of HTTPServlet
2. download the apache xmlrpc zip, unzip it to a directory and add all the JARs to your eclipse project build path (right-klick, Properties, java build path, add external JARs). Make sure you add the JARs to dependencies too (Properties, Java EE Module Dependencies), otherwise they may not get included for tomcat
3. add a generic class to your project that exposes some public methods (e.g. Calculator)
3. change the class from HTTPServlet to XmlRpcServlet (add imports at the top)
4. add an override method for newXmlRpcHandlerMapping

So your class would now look something like this:
public class LoginXmlRpcServlet extends XmlRpcServlet {
	private static final long serialVersionUID = 2009102810561L;
	protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException {
		PropertyHandlerMapping mapping = new PropertyHandlerMapping();
		try {
			mapping.addHandler("Calculator", Class.forName("com.example.YouPackageNameHere.Calculator"));
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			System.exit(1);
		}
		return mapping;
	}
}


(note: this makes step 2 obsolete)
The run and tomcat should start and you should be able to send XML RPC post requests.
Re: XML-RPC (Novice) [message #494011 is a reply to message #493967] Wed, 28 October 2009 18:49 Go to previous message
Jones  is currently offline Jones Friend
Messages: 3
Registered: October 2009
Junior Member
Thanks. I'll try it
Previous Topic:auto complete doesn't work for HTML and CSS
Next Topic:"Named Template XXXX is not available" error
Goto Forum:
  


Current Time: Fri Apr 19 14:28:49 GMT 2024

Powered by FUDForum. Page generated in 0.02672 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top