How to create a web service in eclipse (Creating bottom up web service using tomcat apache)

Configure Tomcat Apache in Eclipse


Windows -> Preferences -> Server -> Run time Environments ->Add
Then you can select your Apache Tomcat server
click next and provide the path of Tomcat Installation Directory
click Finish


Creating the bottom up web service




Download the latest Axis2 binary distribution from here
Now we set Axis2 run time to Eclipse
Windows -> Preferences -> Web services -> Axis2 Preferences
Select Axis2 Runtime tab and give the path to Axis2 Runtime Location.
Then click 'OK'


Now create a dynamic web page by File -> New -> Other -> Dynamic Web Project
Then you come to New Dynamic Web Project Wizard and give name to web project
In this example - WebServiceToPrintName
Here, you have to set configuration by clicking modify button
Then you come to Project facet wizard and select 'Axis2 Web Services'  as a project facet
Then click 'OK'


Now you get new dynamic web page called WebServiceToPrintName
create a package called 'wtp' in the src and create a class called PrintName.java
copy and paste this code in that class


               package wtp;

                                 public class PrintName {

   
                                                public void printMyName(String name){
       
                                                              System.out.println("My Name is : "+name);
       
                                       }
              }
Now select the PrintName class and File -> New -> Other -> Web Services -> Web Service
Then click 'Next'
Set web service type as Bottom up java bean Web Service
Move the service scale to 'Start service'
To set the configuration, click the web service runtime and select Apache Axis2 as web service run time in coming wizard.
Make sure you have selected relevant server and project
Then click 'Next'
In web service wizard, just leave all the fields at the default. (Generate default services.xml file) & click 'Next'
current wizard for starting the server
If you do not start server still, you can start it from here & click 'Next'
Next page is also left as default
click 'Finish'


Then select the project Run -> Run as -> Run on Server
Click 'Next'
Make sure your project is under the configured project on right hand
Click 'Finish'


Then it will display the Axis2 Home Page
click on the services link
The newly created web service is shown there
By clicking on your web service you can get the WSDL for your web service


In next post, Let us see how to use web service by referring created WSDL file

Comments

Popular posts from this blog

How to add standard and custom Metadata to PDF using iTextSharp

How to set and get Metadata to image using BitmapMetadata class in C#

How to generate direct line token to start a new conversation between your own client application and bot framework in Java