Actually i am new for web services so Plz tell me how we can create and implement a web services, and please send any easy example if u have or mail me. [email protected] thanks in advance
**
**
By Vijeta Jaiswal M.Tech(SE/III sem), from SCS&IT, DAVV Indore(MP), India
Email ID: [email protected]
A. Introduction:
In this section we will create a simple web service and client application using eclipse with lamboz. Here we also deploy or test the web service on Apache Tomcat v5.5 server. This section also provide step by step information start from software required to installation to deploye and testing of web service.
B. Software Required for Developing Web services in Java :
C. Steps For Developing Web services in Java
Install Java 6.0(jdk-6u19-windows-i586) in C:/Java/jdk1.6.0_19/
Install Tomcat 5.5 or save it (apache-tomcat-5.5) in D:/apache-tomcat-5.5/
Note: When Tomcat install it ask about jre path(c:/java/jre6.0)
Fig. When jwsdk install it ask about jdk path
Intall Eclipse 3.2(eclipse-SDK-3.2-win32) or save in D:/Eclipse3.2/
Install Lamboz 3.2 (lomboz-all-in-one-R-3.2.2-200706042126-win32) D:/Lamboz3.2/ Link: http://forge.ow2.org/project/showfiles.php?group_id=97
D. Steps for Developing Web Service Example:
Name of Web service:- Radhe_Krishn
Project Name: WebServiceTutorial
Class Name:-Krishna
Method Name:-giveWishes
Package Name: RadheKrishn.Tutorial
**Note:** Method should be start from small letter.
I.Steps:
Do some Setting
Open eclipse in lamboz(D -> Lamboz3.2 -> eclipse -> eclipse) Then
It say for selecting workspace for saving web services or project developed i.e workspace
Fig.Workspace selection
Set up the installed JRE Environment in lamboz -> eclipse( Windows ââ? â?? Preferences ââ? â?? Java ââ? â?? Installed JREs ââ? â?? OK)
Set up the installed runtime for server in eclipse( Windows ââ? â?? Preferences ââ? â?? Serverââ? â?? Installed Runtimes ââ? â?? Add)
Then click to add server and select Apache Tomcat v5.5 Note: It accept only tomcat5v5 not higher than it.
Then select Tomcat Installation Directory(D:/apache-tomcat-5.5/) and click on Finish.
Set up the server view in eclipse( Windows ââ? â?? Show View ââ? â?? Otherââ? â?? Server)
Set up the Tomcat Server by right clicking and selecting (new -> other -> server -> server(click) -> next -> Finish). From this we start tomcat server.
After click on Finish. A window is open which contain Tomcat stopped publish Window
II. Steps for Creating Web Service
1.Create a new Dynamic Web Project in (File-> New -> Other -> web -> Dynamic web project -> Next)
Enter name as ââ?¬Å?WebServiceTutorialââ?¬Â? and select project location as D:/RadheKrishn and select Apache Tomcatv5.5 as the Target (Dynamic web project -> project title -> set location -> Finish) Set location as D:/RadheRadhe and click on Agree button then Yes
Now create a new Java class from the Project Exploser(Windows ââ? â?? New Window ââ? â?? Projce Exposer then click on Dynamic Web Project ââ? â?? Java Resources ââ? â?? New ââ? â??class)
Add a simple method in the �Krishna�class as below.
Package RadheKrishn.Tutorial;
Public class Krishna {
public String giveWishes(String name)
{
return ââ?¬Å?Tathastuââ?¬Â? + name;
}
}
Save the project.
Create a new web service in eclipse(File ââ? â?? New ââ? â?? Other -> web services -> Next)
After click on Next buton
(RadheKrishn.Tutorial.Krishna) and increase the scroll of both Test service and client service.
Then click on Finish button
The browser display the methods available in the web service.
Click on the giveWishes(..) method and enter name(e.g. ââ?¬Å?Vijetaââ?¬Â?) in inputs section and click on ââ?¬Å?Invokeââ?¬Â? button.
Enter name(e.g. ââ?¬Å?Vijetaââ?¬Â?) in inputs section.
click on ââ?¬Å?Invokeââ?¬Â? button and get output.
The WSDL file for RadheKrishna Web service can found in D:\RadheRadhe\WebContent\wsdl\ Krishna.
Right click on the WSDL file and run the web services(Another way to run web service)
Also from above we generate and test the client (Krishna > web service > Generate client)
Conclusion:
In this section we learned how to create a simple web service and client application using eclipse with lamboz. Here we also deploy or test the web service on Apache Tomcat v5.5 server. This section also provide step by step information start from software required to installation to deploye and testing of web service.
Ads