Switch: axis2 configuration and a simple call instance

Source: Internet
Author: User
Recently, a project was to be developed using WebService. I heard axis2 is good, so I downloaded it from Apache. Because I used it for the first time and was not familiar with it, I had to search for articles on the Internet and found that I was online.
There are very few introductions in this regard. Otherwise, it is too simple to get started, so I have to go to the documents provided by axis2. After a few days of study, an instance is called. I will discuss it with you!
I. Environment:
1. jdk1.5 + tomcat5.5 + axis2_1.1.1
2. It seems that JDK 1.4 or above and Tomcat 4.0 or above are required.
Ii. preparations:
1. Download axis2 and download standard binary distribution and war distribution from http://ws.apache.org/axis2.
2. Decompress standard binary distribution, such as: $ axis2_home $ = D: \ axis2-1.1.1.
3. Decompress war distribution
$ Tomcat_home $ \ webapps \ axis2 (Note: You need to manually add the axis2 folder here), or you can refer to the steps in the axis2 document to use
Ant creates an axis2.war, put it under $ tomcat_home $ \ webapps, and then start Tomcat
Tomcat automatically creates an axis2 folder under webapps.
4. Set the environment variables: Create java_home and axis2_home, add the storage addresses of your JDK and axis2, and add their bin to path. This makes it easy to generate a WSDL file.
5. You may also add these *. Jar packages under $ tomcat_home $ \ webapps \ axis2 \ WEB-INF \ Lib to the classpath of the environment variable. Of course, you may not need to use idea.
Iii. test:
1. Start Tomcat and open the browser. Enter http: // localhost: [port]/axis2/to enter the welcome page of axis2. Click "Validate". If no error is reported, it should be said that the environment has been set up !!
2. click the "Administration" initial user name and password are: Admin and axis2, of course you can also go to $ tomcat_home $ \ webapps \ axis2 \ WEB-INF \ conf \ axis2.xml by changing the user name and password.
4. A simple instance
1. The instance is a file under $ axis2_home $ \ samples \ quickstartaxiom. Here there is a service: stockquoteservice. Java, client: axiomclient. Java two java files.
2. Compile the stockquoteservice. Java file. Idea I use
Is intellij. So after compilation, the class file in $ tomcat_home $ \ webapps \ axis2 \ WEB-INF \ Classes
\ [Package]. stockquoteservice. class. I will not talk about package here.
3. Generate the WSDL file. Here we use the built-in axis2 java2wsdl. BAT to generate the WSDL file: Enter the DOS command prompt to $ tomcat_home $ \ webapps \ axis2 \ WEB-INF \ Classes, enter:
Java2wsdl-CP.-CN [Package]. stockquoteservice-of... \ WSDL \ stockquoteservice. WSDL
-CN is the specified class, and-of is to output the file to the specified location. Here I created a WSDL folder under $ atat_home $ \ webapps \ axis2 \ WEB-INF to store the WSDL file.
4. The following can be packaged. The service package in axis2 is named after the suffix. AAR. You can use the following command: ant
Generate. Service (I have never used it ). Another method is to download the plug-in from the Internet. Because intellij is used, download the plug-in and decompress it to the installation file directory plugins.
You can use the plug-in to package the package. After packaging, it should have the following structure:
Stockquoteservice. AAR

-Services. xml
-Stockquoteservice. WSDL

  • Package

-Stockquoteservice. Class
Note: The package should be in the same directory as the META-INF.
5. Upload service. Two methods: 1. Directly import stockquoteservice. AAR
Copy the file to $ atat_home $ \ webapps \ axis2 \ WEB-INF \ Services
Restart tomcat, open the browser, and enter: http: // localhost: [port]/axis2/
Go to the Management page, and click "available services" in the left column to see that the service has been uploaded. 2. in the left column of the management interface, click "Upload
6. In the browser, enter: http: // localhost: [port]/axis2/services/stockquoteservice? WSDL
If yes, OK
Enter http: // localhost: [port]/axis2/services/stockquoteservice? XSD is correct.
It indicates that the service has been deployed.
7. perform a test. Compile axiomclient. Java into a class file and run the command. The result is: current price of WSO: 42. The service call is complete.

Note: In the axiomclient. Java file, note the Port:
Private Static endpointreference targetepr =
New endpointreference (
"Http: // localhost: [port]/axis2/services/stockquoteservice ");

As for other features, such as the transmission mechanism, you can understand it yourself.
Please kindly advise !!!!

Continue Learning -- yxxiao0929

My email: xyx-820929@163.com

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.