Services | Updates | Contact
Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML
Search All Tutorials
Top Search: Loan Struts Open Source
Java: Method FAQs
Q: Do we always have to write a class name in front of static method calls?
 
Linux Basics
Linux is a free open source operating system based on Unix, which runs on varieties of hardware platforms.
 
More Tutorials...

Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

 
 
Web Services
Comments
 
 

 

Building a Simple Web Service – A Tutorial

 ·         By Jeevaraj Gnanaselvan Dhanaraj (jeevaraj_1970@yahoo.com)

      (Jeeva has over 7 years of experience in designing and developing enterprise class web applications using JAVA and J2EE technologies.

      He currently works for Itreya Technologies, Bangalore, leading a team of over 10 programmers and designers, developing a multi-user, distributed, web-based workflow application)

 ·        Introduction

In this tutorial we will create a simple web service and a client web application using eclipse IDE along with Lomboz plug in. We will also deploy and test the web service on Tomcat 5.5.4 web application server. This application, while simple, provides a good introduction to Web service development and some of the Web development tools available.

 ·         Environment

J2SDK 1.4.2
http://java.sun.com/

Eclipse 3.1

http://www.eclipse.org/

Tomcat 5.5.4

http://tomcat.apache.org/

Lomboz 3.1RC2
http://lomboz.objectweb.org/

·         Installation

Install JDK (in D:\j2sdk1.4.2_04)

Install Tomcat (in E:\Tomcat5.5)

Install Eclipse (in E:\Eclipse3.1)

Install Lomboz (in E:\Eclipse3.1)

·         Setting up

  1. Set up the installed JRE in eclipse (Windows -> Preferences -> Java -> Installed JREs)

 

 

  1. Set up the installed runtime for server in eclipse (Windows -> Preferences -> Server -> Installed Runtimes)

 

 

  1. Set up the Server view in eclipse (Windows -> Show View -> Other)

 

  1. 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)

 

  1. Enter name as “WebServiceTutorial”, select project location as “E:\Test” and select Apache Tomcat v5.5 as the Target server.

 

  1. Now create a new Java class from the Project Explorer (Dynamic Web Projects -> Java Source -> New -> Class)

 

 

  1. Enter name as “Hello” and package as “com.tutorial”.

 

  1. Add a simple method in the “Hello” class as below.

            public String sayHello(String name){

                        return "Hello " + name;

            }            

     

 

  1. Save and build the project.
  2. Create a new Web service in eclipse (File -> New -> Other)

 

  1. Select Generate a proxy.
  2. Select Test the Web service.
  3. Select Overwrite files without warning.

 

  1. Select or enter the Bean name as “com.tutorial.Hello”. This is the java class that we just now created.

 

  1. Continue the wizard by clicking Next and finish.
  2. On Finish, the Tomcat server starts up and launches the Test client.
  3. Verify the generated contents. Look for Hello.class and the generated JSPs as below.

 

 

  1. Verify the Tomcat folder and ensure the newly created web applications – WebServiceTutorial, WebServiceTutorialClient.

 

 

  1. We can also run the following url from the browser to access/test the Web service.

http://localhost:8080/WebServiceTutorialClient/sampleHelloProxy/TestClient.jsp

  1. If servlet error “org.eclipse.jst.ws.util.JspUtils cannot be resolved or is not a type” is 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.
  1. The browser displays the methods available in the web service.

 

  1. Click on the sayHello(..) method, enter your name (for e.g. “Jeeva”) in the inputs section and click “Invoke”.

 

 

  1. The browser greets using the web service.

 

  1. 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.

 

 

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

 

 

·         Conclusion

In this tutorial we learned how to create a simple web service and a client web application using eclipse IDE along with Lomboz plug in. We also deployed and tested the web service on Tomcat 5.5.4 web application server. This application, while simple, provides a good introduction to Web service development and some of the Web development tools available.

Facing Programming Problem?
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

13 comments so far (post your own) View All Comments Latest 10 Comments:

Hi
how to resolve this error i.e /hibernate.cfg.xml not found


thanks
rajendra

Posted by rajendra kumar on Wednesday, 04.16.08 @ 14:19pm | #56691

hi sir i want to know the basic web service methods so that i can involk the .net web service from java.plz send an solution for my email id.

Posted by huda on Thursday, 02.28.08 @ 11:34am | #50382

When I start the server from the Eclipse, an error has been encountered i.e

IWAB0213E error in starting server

Please help me out to resolve this issue.

Thanks
Sirish

Posted by sirish on Wednesday, 02.27.08 @ 16:22pm | #50297

Bhagwan,
You have the wsdl url, just link your IDE to it. With the wsdl file you can either download all the stubs or can use dynamic invocation to call the appropriate function on the webservice. I hope this helps you.

Regards,
goodieguy

>Hi..

>This is very good tutorial for those who don't >know how to create web service using eclipse.

>I want to send the data to the exsting web >service of our vender. below is the URL
>https://www.couponzap.com/webservice.php/wsdl?wsdl
>How can achieve this task using eclipse. can you >explain the process?

>Thanx in advance

Posted by goodieguy on Wednesday, 02.13.08 @ 06:24am | #48085

newly craeted wsdl files are not visible and once the running windows are closed i cant find how to run client and server again .Please help

thanks in advance

Posted by alok on Monday, 01.28.08 @ 15:13pm | #46394

Buthow the jsp files got generated, is it automatically?
Can someone answer? or is this the implicit behaviour of the Web service.

Posted by learner on Friday, 01.4.08 @ 05:03am | #44470

This tutoral is developed in eclipse using Lomboz plugin.Can anybody tell me where I will find Lomboz Plugin for Eclipse

Posted by srikanta satapathy on Wednesday, 09.12.07 @ 11:11am | #26818

this is realy nice.i got more point from ur explanation.
give me real time example. and how to create web services using asp.net

Posted by seetharamss on Saturday, 08.18.07 @ 17:27pm | #23661

Hi..

This is very good tutorial for those who don't know how to create web service using eclipse.

I want to send the data to the exsting web service of our vender. below is the URL
https://www.couponzap.com/webservice.php/wsdl?wsdl
How can achieve this task using eclipse. can you explain the process?

Thanx in advance

Posted by Bhagwan on Wednesday, 08.1.07 @ 18:19pm | #22438

pramod i am also facing the same problem if u got the solution please help me.

thanks
prasad

Posted by praasad on Thursday, 07.12.07 @ 10:54am | #21126

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.