Java Web Services, Software Park Thailand, 2004 Apache Axis Apache Axis Dr. Kanda Dr. Kanda Runapongsa Runapongsa Department of Computer Engineering Department of Computer Engineering Khon Kaen University Khon Kaen University 1 Overview Overview � What is Apache Axis � What Apache Axis Provides What Apache Axis Provides � � Axis Installation Axis Installation � � . .jws jws Extension Extension � � Web Service Deployment Descriptors (WSDD) Web Service Deployment Descriptors (WSDD) � � Create Web Services by Axis Create Web Services by Axis � � Exercise Exercise � 2 Dr. Kanda Runapongsa, Khon Kaen University 1
Java Web Services, Software Park Thailand, 2004 What is Apache Axis? What is Apache Axis? � Apache Axis is an open Apache Axis is an open- -source implementation source implementation � that provides a Java- that provides a Java -based SOAP based SOAP implementation for developing Web service implementation for developing Web service � It facilitates a SOAP runtime environment and It facilitates a SOAP runtime environment and � Java- -based API framework for implementing the based API framework for implementing the Java core components of Web services adopting core components of Web services adopting compliant standards and protocols compliant standards and protocols 3 What Apache Axis Provides What Apache Axis Provides � An API library and runtime environment for An API library and runtime environment for � developing SOAP RPC and SOAP messaging- developing SOAP RPC and SOAP messaging -based based applications and services applications and services � A transport A transport- -independent means for adopting a independent means for adopting a variey variey of of � transport protocols (such as HTTP, SMTP, and FTP) transport protocols (such as HTTP, SMTP, and FTP) � Automatic serialization and Automatic serialization and deserialization deserialization for Java for Java � objects to and from XML in SOAP messages objects to and from XML in SOAP messages 4 Dr. Kanda Runapongsa, Khon Kaen University 2
Java Web Services, Software Park Thailand, 2004 What Apache Axis Provides (cont.) What Apache Axis Provides (cont.) � Support for exposing Support for exposing EJBs EJBs as Web services, as Web services, � especially the methods of stateless session EJBs EJBs especially the methods of stateless session � Tools for creating WSDL from Java classes and Tools for creating WSDL from Java classes and � vice- vice -versa versa � Tools for deploying, monitoring, and testing the Tools for deploying, monitoring, and testing the � Web services Web services 5 Axis Installation for Windows Axis Installation for Windows � Java 2 SDK v1.4.2 http:/ / java.sun.com/ j2se/ 1.4.2/ download.html � Apache Tomcat v.5.0.28 http:/ / mirrors.qualsec.net/ apache/ jakarta/ tomc at-5/ v5.0.28/ bin/ jakarta-tomcat-5.0.28.exe � Axis v1.1, http:/ / ws.apache.org/ axis/ dist/ 1_1/ axis- 1_1.zip 6 Dr. Kanda Runapongsa, Khon Kaen University 3
Java Web Services, Software Park Thailand, 2004 Axis Installation (cont.) Axis Installation (cont.) � Unzip Unzip axis-1_1.zip archive to C: (this will create � a directory C:\ axis-1_1) � Copy directory axis in C: Copy directory axis in C:\ \ axis axis- -1_1 1_1\ \ webapps to webapps to � [tomcat directory]\ [tomcat directory] \ webapps webapps (so you have (so you have [tomcat directory]\ [tomcat directory] \ webapps webapps\ \ axis) axis) � Start tomcat server and browse to Start tomcat server and browse to � http:/ / localhost:8080/ axis. Click on the . Click on the http:/ / localhost:8080/ axis Validate link link to test that all libraries are to test that all libraries are Validate accessible to Axis (both core and optional). accessible to Axis (both core and optional). 7 Axis Installation (cont.) Axis Installation (cont.) � The optional libraries can put its into [tomcat The optional libraries can put its into [tomcat � directory]\ directory] \ webapps webapps\ \ axis axis\ \ WEB WEB- -INF INF\ \ lib lib 8 Dr. Kanda Runapongsa, Khon Kaen University 4
Java Web Services, Software Park Thailand, 2004 Axis Environment Axis Environment � Set AXIS_HOME=C: Set AXIS_HOME=C:\ \ axis axis- -1_1 1_1 � � Set AXIS_LIB=%AXIS_HOME% Set AXIS_LIB=%AXIS_HOME%\ \ lib lib � � Set Set � AXISCLASSPATH=% AXISCLASSPATH= %AXIS_LIB AXIS_LIB% %\ \ axis axis. .jar; jar;% %AXIS_ AXIS_ LIB% LIB %\ \ commons commons- - discovery. discovery .jar; jar;% %AXIS_LIB AXIS_LIB% %\ \ commons commons- - logging. .jar; jar;% %AXIS_LIB AXIS_LIB% %\ \ jaxrpc jaxrpc. .jar; jar;% %AXIS_LIB AXIS_LIB% %\ \ sa sa logging aj. .jar; jar;% %AXIS_LIB AXIS_LIB% %\ \ log4j log4j- - aj 1.2.8. .jar; jar;% %AXIS_LIB AXIS_LIB% %\ \ xml xml- - 1.2.8 apis. .jar; jar;% %AXIS_LIB AXIS_LIB% %\ \ xercesImpl xercesImpl. .jar jar apis 9 .jws jws Extension Extension . � Stored in Stored in [tomcat directory] [tomcat directory]\ \ webapps webapps\ \ axis axis � � For example : For example : EchoHeaders.jws. EchoHeaders.jws. � � Compile and executed by browse its URL Compile and executed by browse its URL � � For example browse to : For example browse to : � http:/ / localhost:8080/ axis/ EchoHeaders.jws?wsdl http:/ / localhost:8080/ axis/ EchoHeaders.jws?wsdl � You will see in XML You will see in XML � � The The jwsClasses jwsClasses stored in stored in [tomcat [tomcat � directory]\ \ webapps webapps\ \ axis axis\ \ WEB WEB- -INF INF\ \ jwsClasses jwsClasses directory] 10 Dr. Kanda Runapongsa, Khon Kaen University 5
� � � � � Java Web Services, Software Park Thailand, 2004 Web Service Deployment Descriptors Web Service Deployment Descriptors (WSDD) (WSDD) � Written by using XML. Written by using XML. � � can control which provider handlers are used to can control which provider handlers are used to � expose components as Web services expose components as Web services � Java Java- -RPC Provider RPC Provider � � Java Java- -MsgProvider MsgProvider � � EJBProvider EJBProvider � 11 Axis deployment descriptors � WSDD deployment descriptors � Extensive customization of server options Service style specification � RPC � document � wrapped Allowed methods and required roles Transport specification � Handler chains for special processing Logging or tracking usage Authorization � authentication � Custom serializers � deserializers � Transport specification 12 Dr. Kanda Runapongsa, Khon Kaen University 6
� � � � � � Java Web Services, Software Park Thailand, 2004 Create Web Services by Axis Create Web Services by Axis � Create java file with . Create java file with .jws jws extension extension � � Store it in [tomcat directory] Store it in [tomcat directory]\ \ webapps webapps\ \ axis axis � � Use Java2WSDL to generate . Use Java2WSDL to generate .jws jws to WSDL to WSDL � � Use WSDL2Java to generate 4 Java files from Use WSDL2Java to generate 4 Java files from � WSDL WSDL � Deploy Web Service on Apache Axis Deploy Web Service on Apache Axis � � Create client to call Web Service Create client to call Web Service � 13 Example Example � We will create the Web Service which has three We will create the Web Service which has three � operation that deal with taxes operation that deal with taxes The first operation will figure out the tax percent if given the The first operation will figure out the tax percent if given the subtotal and the total money spent on a shopping purchase. subtotal and the total money spent on a shopping purchase. calcTaxRate(double subtotal, double total) calcTaxRate(double subtotal, double total) The second operation will figure out the amount of tax paid The second operation will figure out the amount of tax paid when given the total and the tax percentage. when given the total and the tax percentage. calcSubTotal(double total, double total, double taxpercent taxpercent) ) calcSubTotal(double The third operation will figure out the total amount when The third operation will figure out the total amount when given the subtotal and the tax percent. given the subtotal and the tax percent. calcTotal(double subtotal, double subtotal, double taxpercent taxpercent) ) calcTotal(double 14 Dr. Kanda Runapongsa, Khon Kaen University 7
Recommend
More recommend