Creating a web service or a web service client using Eclipse IDE is really simple and doesn't take more than several minutes.
Following is a quick and easy guide for that.
I am using Eclipse Indigo for this.
1. Create a new Dynamic Web Project.
2. Select Apache Tomcat as the target runtime.
3. Right click on src folder, create a new java class and name it as 'Clock'.
4. Add getDate() method to the 'Clock' class as below. The method should be public.
5. Now we are going to create the web service based on this class. Right click on the 'Clock' class, then select -> Web Services -> Create Web Service
6. You will see the following screen. Click 'Next' to see what methods are going to be in Web Service or simply click 'Finish'.
7. If you clicked 'Next', you will see a page like below where you can select methods to be visible in Web Service.
Click 'Finish'.
8. This will create Clock.wsdl, web.xml and some other important files. See below image.
9. And your application is now automatically deployed in Tomcat server.
To check this, in your web browser go to http://localhost:8080/TimeService/services/Clock
You will see a page like this.
Congratulations!! You have successfully published the web service.
Now we are going to create a client which consumes this web service.
(Note that the client should not necessarily be a web application.)
10. Create a new Java Project. Name it as 'TimeClient'.
11. We need the WSDL file to create the Web Service Client. So copy the WSDL file from your TimeServer project to TimeClient project.
12. Now right click on this WSDL file -> Web Services -> Generate Client
You will get following screen.
Click 'Finish'.
13. Now right click on the src folder and create a new class. This is the class to which you are going to add your methods which calls the Web Service.
Name the class as 'ClockClient'.
14. Add a main method to 'ClockClient' class as below and run it.
15. You will get an output printed on your console as below.
Your client has successfully consumed the web service you created...
Great job . Useful to learn basics of web service
ReplyDeleteGreat Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
ReplyDeleteonline Python training
python training in chennai
I think you have a long story to share and i am glad after long time finally you cam and shared your experience.
ReplyDeleteData Science course in Chennai
Data science course in bangalore
Data science course in pune
Data science online course
Data Science Interview questions and answers
Data Science Tutorial
Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
ReplyDeleterpa training in bangalore
best rpa training in bangalore
rpa training in pune | rpa course in bangalore
rpa training in chennai
Hey, thanks for the blog article.Really thank you! Great.
ReplyDeletedata science training
python training
angular js training
selenium trainings
sql server dba training
Thanks for the information... I really love your blog posts..
ReplyDeleteBiotech Internships | internships for cse students | web designing course in chennai | it internships | electrical engineering internships | internship for bcom students | python training in chennai | web development internship | internship for bba students | internship for 1st year engineering students
I’m happy I located this blog! From time to time, students want to recognize the keys of productive literary essays. Your first-class knowledge about this good post can become a proper basis for such people. nice one
ReplyDeletedata analytics courses in hyderabad with placements