Java JDK/JRE 1.5.0_04 (mind that jdk 1.4 may have some Axis_Fault problems)
Tomcat 5.5.9
Axis 1.2
set environment by configure myComputer->property->system env. as follows:
JAVA_HOME C:\Java\jdk1.5.0_04
AXIS_HOME D:\api\axis
AXIS_LIB %AXIS_HOME%\lib
JENA_HOME D:\api\Jena-2.3
AXISCLASSPATH %AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discovery-0.2.jar; %AXIS_LIB%\commons-logging-1.0.4.jar;%AXIS_LIB%\jaxrpc.jar;%AXIS_LIB%\saaj.jar;%AXIS_LIB%\log4j-1.2.8.jar;%AXIS_LIB%\xml-apis.jar;%AXIS_LIB%\xercesImpl.jar
CLASSPATH .;%JENA_HOME%\lib\antlr.jar;%JENA_HOME%\lib\concurrent.jar;%JENA_HOME%\lib\commons-logging.jar;%JENA_HOME%\lib\icu4j.jar;%JENA_HOME%\lib\jakarta-oro-2.0.5.jar;%JENA_HOME%\lib\jena.jar;%JENA_HOME%\lib\junit.jar;%JENA_HOME%\lib\log4j-1.2.7.jar;%JENA_HOME%\lib\xercesImpl.jar;%JENA_HOME%\lib\xml-apis.jar;%AXISCLASSPATH%;%JAVA_HOME%\lib\tools.jar;C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\axis.jar;%AXIS_LIB%\wsdl4j-1.5.1.jar;D:\api\jaf-1.0.2\activation.jar;D:\api\javamail-1.3.3_01\mail.jar;D:\api\xml-security-1_3_0\libs\xmlsec-1.3.0.jar
PATH C:\Program Files\SSH Communications Security\SSH Secure Shell;C:\Program Files\CVSNT\;C:\java\jdk1.5.0_04\bin
Integrate axis into tomcat: copy D:\api\axis\webapps\axis to C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps
check axis happy-page on http://localhost:8080/axis/happyaxis.jsp
following the directions on the happy-axis page, get
activation.jar (jaf-1.0.2), http://java.sun.com/products/javabeans/glasgow/jaf.html
mail.jar (javamail-1.3.3_01), http://java.sun.com/products/javamail/downloads/index.html
xmlsec.jar etc(xml-security-1_3_0/lib), http://xml.apache.org/security/dist/java-library/
and put them in classpath. (as shown in the last three items in the classpath above)
stop and restart tomcat server, refresh happy-axis page, which should be error free by now.
then we start with a simple service java file:
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.*;
import java.util.regex.*;
import java.lang.*;
public class WebServiceTest{
public String doTest(String in) throws RemoteException
{
return "input is "+in;
}
}
compile it and copy the result WebServiceTest.class to
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\classes
manually edit deploy.wsdd, as follows:
make sure Tomcat webserver is runing.
Deploy the webservice:
java org.apache.axis.client.AdminClient deploy.wsdd
this will register the class in the axis engine so that they are exposed properly as a web service.
***** make sure you have compiled the WS.java and copy the result WS.class to
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\classes ***.
go to http://localhost:8080/axis/servlet/AxisServlet
the web service should have already been registered there.
so far, the server side is done.
next we need to make a client that calls the web service:
get the web services's WDSL link from http://localhost:8080/axis/servlet/AxisServlet
run java org.apache.axis.wsdl.WSDL2Java
As it seems that the WSDL2Java does not generate a handy proxy file. yet althought IBM websphere developer does generate the proxy java file, its other helpper java files uses ibm's own jars, which is not good. For these, we now need to make good use of both:
1. run IBM Websphere developer 5.1.2. new->web project; new->other->web service client; give it the WSDL link. and follow the wizard, it will generate all helpper java files including a proxy java file. Copy (drag and drop) all the WSDL2java generated helper files to IBM Websphere java source to replace IBM Websphere generated helper java files. change moderate on the packages name, etc.
2. create a tester java file that call the web service by using the proxy java class object:
package localhost;
public class Tester
{
public static void main (String [] args) throws Exception{
//make a service
WSProxy service= new WSProxy();
System.out.println(service.doTest("2222"));
//
}}
Done!
No comments:
Post a Comment