How to use webservices in j2ee platform

hi experts,

                 i want to know more about webservices. Plz provide right solution and implementation on eclipse using weblogic or tomcat with examples using  java and j2ee . plz provide good info on services.

Thanks in advance

Who is Participating?
Ajay-SinghConnect With a Mentor Commented:
You can WST plugin, here is a nice documentation
wasawasConnect With a Mentor Commented:
Hi, Srinudumpala

I recommend you to use Eclipse version: "All-In-One Eclipse" or "Lomboz" (use these as keyword to find and download).

Your question has a lot of thing to learn but the right way to create project in Eclipse for a Web Service should be:

1. Go File ->New -> Project...
2. Select "Web" -> "Dynamic Web Project" then click next
3. Put your "Project Name" and Select "Target runtime"
     Note: At the first time your eclipse will not be recognize any thing about "Target runtime" so you must press "New" to add the new one into the list.  
     3.1 From "New" button the dialog of Web Application Server will appear.
           You can select which one you want:
                      BEA Systems -> Generic BEA WebLogic Server 9.0
                      Apache -> Apache Tomcat 5.5
     3.2 After you select Web Application Server you will get the dialog for setting the Web Application Server where the place it's installed and what is your JRE.  Each Web Application Server should be different setting For Tomcat should be:

                Name:      Apache Tomcat V5.5
                Tomcat Installation Directory:    C:\Tomcat5.5   [Browse..]
                JRE:  jdk142_08    [Installed JREs]

           If you haven added JRE to your Eclipse yet, you must press "Installed JREs" to the dialog to add JRE, just put name and specify the directory that JDK installed.
     3.3  Then click "Finish"
4. Click "Finish" to start create new project process.

Now you got the project for Web Service. Next you must set your Eclipse Workspace to recognize Axis and Ant (You should learn more about howto apply Axis to Tomcat and what's Ant can do here will explain just a little). Go follow this step to set Axis to Eclipse

[Axis in Eclipse]
1. Click menu  Windows -> Preferences  
2. Select "Axis Runtime" from the left menu.
3. Input "Version" and "Axis Home"  it should be completed with All-In-One Eclipse version as
       Version :   1.2
       Axis Home :       c:\eclipse\plugins\org.apache.axis_1.2.1.v200602062208
4. From Package Explorer menu open "web.xml" from  WebContent -> WEB-INF->web.xml
5. Put the below config to apply Axis to your Web Application



6.  Edit others config for your servlets (Learn more about servlet)
7. Save the web.xml file

[Create the runtime Server for run Tomcat in Eclipse]
1. Click menu Window -> Show View -> Other..
2. Select  Server -> Servers
3. The Servers View should be appear on the buttom then right click somewhere on Servers View.
4. Select New -> Server  then select your Runtime Server as Tomcat version that you have created then click "Next".
5. In Add and Remove Project add your project from Available Project to Configured Project.(If does not have your project in the list that imply you didn't create project correctly. Make sure you created the project as Dynamic Web Project)
6. Then click "Finish"
Now you can run your Web Application by click at Start at the Server in Server View.

[install Axis in Tomcat]
1. Download Axis from Axis homepage
2. Extract it compress file then you should get the webapps folder name: "axis" in the uncompress folder. You can notice the  "axis" is the correct one by checking inside folder should has "WEB-INF" folder.
3. Copy the "axis" folder to your <TOMCAT_HOME>/webapps

[Set Ant in Eclipse]
1. Click menu Window -> Preferences
2. Select from the left menu  Ant -> Runtime
3. In the right Rumtime config page will display then select "Classpath" tab
4. Click "Ant Home..." button
5. Select the Ant's home directory  (If you does not install Ant yet please do it first)
6. Click "OK" and "OK"

//  General Step For Web Service       //
1. First of all for Web Service  you should have the API for your service they are specified by WSDL file.  So learn how to write the WSDL or write Java class and use Ant to convert  Java2Wsdl.
2. After you have your service specification WSDL then you just use Ant run the task with Wsdl2Java to generate set of Java class SOAP API.
3. Check your understanding about your project gonna be  SOAP client or server.
4. Then write the java code as:
                     [For SOAP server]
                         1. Re-Write the interface of your service method which should be named as
                         2. That enough
                     [For SOAP client]
                         1. Create servlet to obtain parameters from the request.
                         2. In the servlet code should create instance of the Locator of the service.
                         3. Then pass the parameters by calling the method from that Locator.

These are all steps to do actually with create Web Service.  So the examples and detail of these step can be found from the internet try to use keywords in these description you will found a lot.  Your question should take time quite a lot till you get your Answer.

Good luck.
Forced accept.

EE Admin
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.