WebService axis2 series tutorial (1) download, install and use axis2

Source: Internet
Author: User
Tags custom name

Axis2 is a popular WebService engine. WebService is applied in many different scenarios. For example, you can use WebService to publish methods of the Java class on the server side, so that different clients can be called. In this way, different technologies can be effectively integrated to complete the application system. WebService is also frequently used in SOA to exchange data between various parts of SOA. This course focuses on the core functions of axis2 and provides three projects to help you understand and understand how to apply axis2 to different scenarios.

This course introduces most common functions of axis2 from the perspective of beginners, for example: write and publish WebService, jax-rpc, JAX-WS, complex transmission, WebService session management, and axis2 modules in multiple ways

Axis2 is a brand new WebService engine. This version is the product of the redesign of axis1.x. Axis2 not only supports soap1.1 and soap1.2, but also integrates the popular rest WebService and spring and JSON technologies. These will be explained in the subsequent series of tutorials.


The following software versions are for your own use

My eclipse 10.0

Tomcat 6.0


The following two are myeclipse plug-ins (http://axis.apache.org/axis2/java/core/tools/index.html)



The following zip package is Tomcat plug-in (http://axis.apache.org/axis2/java/core/download.cgi)


Jar packages in axis2 need to be used in client development



Install the myeclipse plug-in (see
Unzip axis2-eclipse-codegen-plugin-1.6.0.zipand axis2-eclipse-service-plugin-1.6.0.zip
D: \ Users \ Administrator \ appdata \ Local \ myeclipse is the root directory of myeclipse installation.

Copy the jar package in the decompressed plugins to the Plugins in common under the installation directory of myeclipse (only the jar package is required), as shown in:
D: \ Users \ Administrator \ appdata \ Local \ myeclipse \ common \ plugins

Go to org. Eclipse. Equinox. simpleconfigurator in the myeclipse installation directory, as shown below:
D: \ Users \ Administrator \ appdata \ Local \ myeclipse 9 \ Configuration \ org. Eclipse. Equinox. simpleconfigurator

Use NotePad to open the bundles.info file in org. Eclipse. Equinox. simpleconfigurator.

Add the following content to the bundles.info file.
Org. apache. axis2.eclipse. codegen. plugin, 1.6.0, file:/D:/users/Administrator/appdata/local/myeclipse/common/plugins/org. apache. axis2.eclipse. codegen. plugin_1.6.0.jar, 4, false

Org. apache. axis2.eclipse. service. plugin, 1.6.0, file:/D:/users/Administrator/appdata/local/myeclipse/common/plugins/org. apache. axis2.eclipse. service. plugin_1.6.0.jar, 4, false

After myeclipse is started, Click create other. If there are two contents in the axis2 wizards folder, the installation is successful.


Tomcat installation
Unzip tomcat6.0 to a directory. The installation-free version is used here.

Add the following to the system environment variable:
Tomcat_home = D: \ WebService \ tomcatapache-tomcat-6.0.32
Catalina_base = D: \ WebService \ Tomcat \ apache-Tomcat-6.0.32
Catalina_home = D: \ WebService \ Tomcat \ apache-Tomcat-6.0.32

% Tomcat_home %/lib

Enter http: // localhost: 8080 in the browser. The Tomcat homepage indicates that the installation is successful.


Decompress axis2-1.6.0-war.zip to obtain an axis2.war file. copy the file to the D: \ WebService \ Tomcat \ apache-Tomcat-6.0.32 \ webapps directory.

After Tomcat is started, an axis2 folder is automatically generated. The folder is in D: \ WebService \ Tomcat \ apache-Tomcat-6.0.32 \ webapps.

Enter http: // localhost: 8080/axis2/in the browser to see

Indicates that the axis2 web server is successfully set up.
The development environment has been set up.


Server Release
Start myeclipse to create a Java Project
Write a server class and return a string to the client.

package com.test;public class Test { public String server(String name) {  return "Hello " + name; }}

1. Right-click the current project and select export.


Select the current project and Click Browse to select the jar input directory and enter the generated jar package file name.

Click Finish to complete jar package Packaging

Package arr
Right-click newotheraxis2 wizardsaxis2 service archiver in this project


Select the ARR package, enter the directory, and click Next


Select skip wsdlnext

Click brows, select the jar package that has been packaged, and click Add à next.

Select Check box next


Enter your own servername, enter the complete class name, and click load. All the methods in this class are displayed below. If this method is selected, it will be released, and the customer can call this method after dropping it.

For nextbrowse, select output file location, select the data path of the ARR file, enter the name of the ARR file, and click Finish.


Release arr, copy the packaged arr file to the D: \ WebService \ Tomcat \ apache-Tomcat-6.0.32 \ webapps \ axis2 \ WEB-INF \ Services Directory, restart tomcat, enter http: // localhost: 8080/axis2 in the browser and click Service to go to the following page:


You can see testaxis (custom name when arr is packaged). Click testaxis to view XML, indicating that the release is successful and can be called on the client.


Create a Java project and write the client code.
Right-click newother axis2 wizardsaxis2 code generatornext


Select the first radio button next


Enter http: // localhost: 8080/axis2 in the browser
--> Select Services --> testaxis to go to an XML interface and copy the address (http: // localhost: 8080/axis2/services/llspserver? (WSDL), paste it to the WSDL
File Location, click Next

Keep default, next


Select the project of the client. The output PATH value is the project of the new client. nextokfinish


In the package packages in the myeclipse interface, import all the jar files in lib to the client project.

Create a new class test in the axisclient Project

Import Java. RMI. remoteException; import COM. test. server; import COM. test. testaxisstub; public class testclient {public static void main (string ARGs []) throws RemoteException {// first create a stub object (pile) testaxisstub TAS = new testaxisstub (); // instantiate the server method Object Server s = new server (); // set the parameter S for the server method. setname ("John"); // execute this method and accept the return value string STR = TAS. server (s ). get_return (); system. out. println (STR );}}

Start Tomcat and run test. Java to obtain the value returned by the server.



Download the tutorial source code:






Reprint please indicate the source http://blog.csdn.net/shimiso

Welcome to our technical exchange group: 173711587

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.