[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 699
  • Last Modified:

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

sinu
0
srinudumpala
Asked:
srinudumpala
2 Solutions
 
Ajay-SinghCommented:
You can WST plugin, here is a nice documentation
http://www.eclipse.org/webtools/initial-contribution/IBM/evalGuides/WebServi
cesToolsEval.html
0
 
wasawasCommented:
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:
           Eg.  
                      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
eg.
       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

  <display-name>Apache-Axis</display-name>
  <servlet>
    <servlet-name>AxisServlet</servlet-name>
    <servlet-class>
        org.apache.axis.transport.http.AxisServlet
    </servlet-class>
  </servlet>

   <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/servlet/AxisServlet</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
  </servlet-mapping>
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
                             xxxxxxxxxxBindingImpl.java
                         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.
 
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now