Monday, 4 April 2016

Building a simple Web service using Lomboz eclipse plugin


Create a simple web service and a client web application using eclipse IDE along with Lomboz plugin. Also deploy and test the web service on Tomcat 5.5x.

Environment
If you have Eclipse Europa, there is no need of Lomboz plugin.
J2SDK1.4.2, Eclipse3.1, Tomcat5.5.4, Lomboz 3.1RC2 (http://lomboz.objectweb.org)

Setup
1. Set up the installed JRE in eclipse (Windows - Preferences - Java - Installed JREs)
2. Set up the installed runtime for server in eclipse (Windows - Preferences - Server - Installed Runtimes)
3. Set up the Server view in eclipse (Windows - Show View - Other)
4. Set up the Tomcat Server by right clicking and selecting New - Server option from the Server view in eclipse


Creating a Web service

1. Create a new Dynamic Web Project in eclipse (File - New - Other)
2. Enter name as WebServiceTutorial”, select project location as “E:\Test” and select Apache Tomcat v5.5 as the Target server.
3. Now create a new Java class from the Project Explorer (Dynamic Web Projects - Java Source - New - Class)
    Enter name asHelloand package as com.tutorial”. Write some code in main() method of class.
4. Save and build the project.
5. Create a new Web service in eclipse (File - New - Other)
  • Select Test the Web service.(To test using JSP)
  • Select or enter the Bean name ascom.tutorial.Hello. This is the java class that we just now created.
  • Continue the wizard by clicking Next and finish.
  • On Finish, the Tomcat server starts up and launches the Test client.
  • Verify the generated contents. Look for Hello.class and the generated JSPs.

6. Verify the Tomcat folder and ensure the newly created web applications – WebServiceTutorial, WebServiceTutorialClient.
We can also run the following url from the browser to access/test the Web service.
http: //localhost:8080/WebServiceTutorialClient/sampleHelloProxy/TestClient.jsp

If servlet error org.eclipse.jst.ws.util.JspUtils cannot be resolved or is not a typeis thrown on the browser, then copy the webserviceutils.jar file from the E:\Eclipse3.1\eclipse\plugins\org.eclipse.jst.ws.consumption_0.7.0 into the WEB-INF\lib folder of the WebServiceTutorialClient application and restart the Tomcat server.
The browser displays the methods available in the web service.
Click on any method, enter your name in the inputs section and click “Invoke”.

The WSDL for the Hello Web service can be found in E:\Test\WebServiceTutorial\WebContent\wsdl\Hello.wsdl.
On double-click, the WSDL opens in a graphical editor.

Right-click on the WSDL file and explore the options to test the web service - publish the WSDL file, generate client etc.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.