August 27, 2009 5 Comments
Apache Axis2 provides the facility of deploying JAXWS web services. If you have a JAXWS web service which is written using standard JAXWS annotations, this post will help you to deploy your service in Axis2.
Step 1 : Create a .jar file including your .class files with their packages. Structure of a sample service is shown below.
If you have a WSDL for your service, you can include the WSDL in the root level of the jar file and add the “wsdlLocation” within your “@WebService” annotation which is in your service class. And also you have to provide “serviceName” and “portName” as it is in the WSDL. A Sample annotation is shown below.
If you don’t include the WSDL in your service, Axis2 will try to generate the WSDL for you. But it is better to include your WSDL rather than depending on the generated WSDL. For complex services, WSDL generation may fail.
If you have any libraries on which your service is depending on, you can include those in a “lib” folder at the root level of your .jar archive.
Following image shows the root level structure of your .jar file. WSDL and the “lib” folder are optional.
Step 2 : Download Axis2 1.5 binary distribution (or you can build Axis2 trunk from the source) and extract it. Create a AXIS2_HOME/repository/servicejars directory and copy your .jar file which is created in Step 1 into servicejars directory.
Step 4 : Start the server using AXIS2_HOME/bin/axis2server.sh (or .bat). You can see an INFO log on the console on the service deployment.
Step 5 : Access http://localhost:8080/axis2/services from your browser. You can see the deployed JAXWS service and you can see the WSDL by clicking on it. Use some tool like “soapui” to invoke the service by providing the WSDL URL.