Google
 

Wednesday, June 11, 2008

Creating an axis webservice

Pre-Requisites
1) Tomcat 5.0
2) Apache axis 1.4
3) jdk 1.4.2

Copy the axis folder (inside D:\axis-1_4\webapps) into Tomcat webapps folder.

1) Create a simple java program
package com.samples.webservice;

class HelloWorld
{
public String displayName(String name) {
return "Hello " + name;
}
}

2) Copy the class file along with the package structure into D:\Tomcat 5.0\webapps\axis\WEB-INF\classes folder.

3) Create a WSDD file - deploy.wsdd







3) Deploy it as a web Service
java -classpath E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\axis.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\mail.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\jaxrpc.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\
commons-logging-1.0.4.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\
lib\commons-discovery-0.2.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\
lib\saaj.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\activation.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\activation-1.1.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\mailapi_1_3_1.jar org.apache.axis.client.AdminClient deploy.wsdd

4) Access the service by using the url http://localhost:8080/axis/services/HelloWorld

5)Create a client program to access this service
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.ParameterMode;

public class HelloWorldClient {
public static void main(String [] args) {
try {
String endpoint =
"http://localhost:8080/axis/services/HelloWorld";

Service service = new Service();
Call call = (Call) service.createCall();

call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName( "displayName" );
call.addParameter( "op1", XMLType.XSD_STRING, ParameterMode.IN );
call.setReturnType( XMLType.XSD_STRING );
String ret = (String) call.invoke( new Object[] { "Srikant !!" } );
System.out.println("Sent 'Srikant !!', got '" + ret + "'");
} catch (Exception e) {
System.err.println(e.toString());
}
}
}

Compile it using -----
javac -classpath E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\axis.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\jaxrpc.jar HelloWorldClient.java

Run the program using -----
java -cp .;E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\axis.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\jaxrpc.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\commons-logging-1.0.4.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\commons-discovery-0.2.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\saaj.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\activation.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\mailapi_1_3_1.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar HelloWorldClient

6) To generate Client program using WSDL File
a) java -cp .;E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\axis.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\jaxrpc.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\commons-logging-1.0.4.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\commons-discovery-0.2.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\saaj.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\activation.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\mailapi_1_3_1.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\endorsed\xercesImpl-2.6.2.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\endorsed\xml-apis-2.6.2.jar org.apache.axis.wsdl.WSDL2Java testsap.wsdl

b) Compile the generated classes.

c) Write a standalone java file to invoke the client as follows

class TestHelloWorld
{
public static void main(String[] args)
{
try
{
System.out.println("Hello World Starts!");
helloworld.HelloWorldService hws = new helloworld.HelloWorldServiceLocator();
helloworld.HelloWorld hw = hws.getHelloWorld();
hw.displayName("Srikant........");
System.out.println("Hello World Ends!");
}
catch (java.rmi.RemoteException rmiEx)
{
System.out.println("RMI Exception is :: " + rmiEx.getMessage());
}
catch (javax.xml.rpc.ServiceException serEx)
{
System.out.println("Service Exception is :: " + serEx.getMessage());
}
}
}

Compile this file :: javac -classpath .;./helloworld;E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\axis.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\jaxrpc.jar TestHelloWorld.java

d) Run this file
java -cp .;E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\axis.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\jaxrpc.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\commons-logging-1.0.4.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\commons-discovery-0.2.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\saaj.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\activation.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\mailapi_1_3_1.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar TestHelloWorld


7) To generate WSDL file from a deployed service
java -cp .;E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\axis.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\jaxrpc.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\commons-logging-1.0.4.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\commons-discovery-0.2.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\saaj.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\activation.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\mailapi_1_3_1.jar;
E:\Softwares\servers\apache-tomcat-5.5.25\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar org.apache.axis.wsdl.Java2WSDL -o helloworld.wsdl -l http://localhost:8080/axis/services/HelloWorld -n "urn:helloworld" -p"com.samples.webservice" "urn:helloworld" com.samples.webservice.HelloWorld



********************************************************************************************************
java -classpath D:\Dumps\Software\axis-1_4\lib\axis.jar;
D:\Dumps\Software\axis-1_4\lib\jaxrpc.jar;
D:\Dumps\Software\axis-1_4\lib\commons-logging-1.0.4.jar;
D:\Dumps\Software\axis-1_4\lib\commons-discovery-0.2.jar;
D:\Dumps\Software\axis-1_4\lib\saaj.jar;
D:\Dumps\Software\axis-1_4\lib\activation.jar;
D:\Dumps\Software\axis-1_4\lib\mailapi_1_3_1.jar;
D:\Dumps\Software\axis-1_4\lib\endorsed\xml-apis-2.6.2.jar;
D:\Dumps\Software\axis-1_4\lib\endorsed\xercesImpl-2.6.2.jar org.apache.axis.client.AdminClient deploy.wsdd

D:\Dumps\Software\axis-1_4\lib

java -cp .;D:\Dumps\Software\axis-1_4\lib\axis.jar;
D:\Dumps\Software\axis-1_4\lib\jaxrpc.jar;
D:\Dumps\Software\axis-1_4\lib\commons-logging-1.0.4.jar;
D:\Dumps\Software\axis-1_4\lib\commons-discovery-0.2.jar;
D:\Dumps\Software\axis-1_4\lib\saaj.jar;
D:\Dumps\Software\axis-1_4\lib\activation.jar;
D:\Dumps\Software\axis-1_4\lib\mailapi_1_3_1.jar;
D:\Dumps\Software\axis-1_4\lib\wsdl4j-1.5.1.jar;
D:\Dumps\Software\axis-1_4\lib\endorsed\xml-apis-2.6.2.jar;
D:\Dumps\Software\axis-1_4\lib\endorsed\xercesImpl-2.6.2.jar org.apache.axis.wsdl.Java2WSDL -o cureservice.wsdl -l http://localhost:8080/axis/services/CUREWebService -n "urn:CUREWebService" -p"com.cadence.cure.webservice" "urn:CUREWebService" com.cadence.cure.webservice.CUREWebService


java -cp .;D:\Dumps\Software\axis-1_4\lib\axis.jar;
D:\Dumps\Software\axis-1_4\lib\jaxrpc.jar;
D:\Dumps\Software\axis-1_4\lib\commons-logging-1.0.4.jar;
D:\Dumps\Software\axis-1_4\lib\commons-discovery-0.2.jar;
D:\Dumps\Software\axis-1_4\lib\saaj.jar;
D:\Dumps\Software\axis-1_4\lib\activation.jar;
D:\Dumps\Software\axis-1_4\lib\mailapi_1_3_1.jar;
D:\Dumps\Software\axis-1_4\lib\wsdl4j-1.5.1.jar;
D:\Dumps\Software\axis-1_4\lib\endorsed\xercesImpl-2.6.2.jar;
D:\Dumps\Software\axis-1_4\lib\endorsed\xml-apis-2.6.2.jar org.apache.axis.wsdl.WSDL2Java cureservice.wsdl

9 comments:

Uritha Shiks said...

123 HP Deskjet 3830 Printer Setup, 123 HP Deskjet 3830 Printer Setup, 123 HP Deskjet 3830 Printer Setup, 123 HP Deskjet 3830 Printer Setup

mark john said...

123.hp.com/envy 5661

jerome ken said...

123.hp.com/dj3730

Ritchie ken said...

123.hp.com/oj5255

Gaju Mekha said...

123.hp.com/oj6962

lucasharper said...

Very nice blog...... Hot Tot Hair Products seems to be very useful.... I would like to try them if i could buy them in Australia.... Nice work, keep it up.


hp officejet 3830 connect to computer

Avaliam said...

Thank you for using my Guide and if it work for you that makes me happy


123.hp.com/oj3830 Setup

Officesetup said...

If you search best technical support for TurboTax Support and Office.com/setup then you can visit here and resolve you problem immediately. Because our expert always provide the best and satisfy solution.

Office.com/setup
TurboTax Support
123hp.com/setup

Technical Assistance said...

office is a versatile range of products that help you to complete a task with less efforts, complete office.com/setup procedure to explore its products.
Office.com/setup - Office Login | Office Setup | MS Office 365
Office Setup & Login | Office.com/myaccount | Office.com/setup
Office.com/myaccount | Office 365 Login / Sign In Account
Blog - Office.com/setup
Privacy Policy - Office.com/setup
Disclaimer - Office.com/setup