You are on page 1of 9

Create Web Service with Eclipse, GlassFish and Axis2

Prerequisites

1. Eclipse latest version ( Here I am using Ganymede version)

2. glassfish-installer-v2ur2-b04-windows.jar to install GlassFish


3. com.sun.enterprise.jst.server.sunappsrv_1.0.17.jar eclipse plugin
4. axis2-1.4.1
5. apache Ant – any version will do
6. JDK1.6

Installation Procedure

Eclipse Installation

Extract the downloaded Eclipse folder to C drive.

GlassFish Eclipse plugin Installation

Copy com.sun.enterprise.jst.server.sunappsrv_1.0.17.jar file to Eclipse plugin directory.

JDK1.6 Installation

Double click on the download jdk installation file and follow the installation procedure.
Keep default installation path as it is.

Ant Installation

Extract the downloaded Apache-ant folder to C drive.

Axis Installation

Extract the downloaded Axis2 folder to C drive.


GlassFish Installation

1. copy GlassFish installer jar to C drive


2. Start > Run type cmd. This will open command prompt.
3. type c: (this will bring you to C drive).
4. type java –Xmx256m –jar glassfish-installer-v2ur2-b04-windows.jar
5. This will open GlassFish installer. Accept the Terms and Conditions.
6. After successful installation you will see new folder named glassfish will get
created in c drive.
7. Goto c:\glassfish\setup.xml change the default port number 8080 to some
port number and save the file

8. Do the same thing in setup-cluster.xml file.


9. type Apache-ant\bin\ant –f c:\glassfish\setup.xml in command prompt.
10. Apache-ant\bin – this location will be your apache ant location where you have
installed your Apache-ant
11. After successful installation you will get following screen

12. Goto C:\glassfish\config\asenv.bat and change the AS_HOME entry as


AS_HOME = C:\Program Files\JDK1.6\jre
Let’s Start to devlope and Deploy Web Service

1. Open Eclipse. Go to Server View.

2. Right click there goto New > Server. Select GlassFish v2 Java EE 5
3. Click on Configure runtime environments… link edit GlassFish runtime as show below.

4. It will create entry in Server view as follows. Server set up is now finish.

5. To Configure Axis2 goto Window > Preferences > WebService


Give “Axis2 Preferences” & “Servers and Runtime” shown in figures.
6. Create new Dynamic Project “Hello”.

7. Create HelloService class under example package. Following object have HelloService
code.
D:\Axis Test Run\
HelloService.java
8. Select HelloService.java now goto File > new > other > Web Service

9. Configure Server and Web service runtime as show above. Say Next to subsequent
screens.
10. In the last screen press Start Server button. After processing Next button will get
activated. Press it.

11. The above procedure will create wsdl file. The same project will get deployed on the
server.
12. Right click on the Hello project Run As > Run on server. It will open Axis welcome screen.
13. Click on Services > HelloService. It will open xml file

14. Copy the url show in red block by pressing ctr+c.


15. Create new Dynamic Project name it HelloClient
16. Goto File > New > Other > Web Service Client
17. Paste the copied url in Service Definition. Check for Server and Web service runtime.
18. Make sure Client project name sould be HelloClient and Client EAR poject should be
HelloClientEAR. We can change these name by clicking particular link and editing the text
in the combobox.
19. Proceed the screens by clicking Next button. At last screen click on Finish button.
While proceeding accepts the defaults as provided by screen.
20. This will create HelloServiceStub.java and HelloServiceCallbackHandler.java as shown.

21. Write HelloClient class and test it. Following object have HelloClient code.

D:\Axis Test Run\


HelloClient.java

You might also like