Axis2, what's that?
At first, we should pay enough sight to Axis2, as which home page say that "
Apache Axis2 is the core engine for Web services. It is a complete re-design and re-write of the widely used Apache Axis SOAP stack."
And this describe
" Apache Axis2 not only supports SOAP 1.1 and SOAP 1.2, but it also has integrated support for the widely popular REST style of Web services . The same business logic implementation can offer both a WS-* style interface as well as a REST/POX style interface simultaneously.
Apache Axis2 is more efficient, more modular and more XML-oriented than the older version. It is carefully designed to support the easy addition of plug-in "modules" that extend their functionality for features such as security and reliability. "
More info can find in
Ok, let's show we case of this cool tool, please allow me call she like this.
Case
Here we will implement an CalculateService, which include plus,minus,multiply and divide method.
And we use axis2 1.4.1 to deploy as an Web service.
Follow me, let's do it!
setp one
Before you do it, you should download axis2 1.4.1 from http://ws.apache.org/axis2/index.html
download this version named "axis2-1.4.1-bin.zip", then unzip it to some dirctory, here i use "E:\Java_dev\axis2-1.4.1".
setp two
Setting your eclipse's webservices "axis2 preferences" item, set which runtime to E:\Java_dev\axis2-1.4.1, and now the whole setting is over, next setp is to make this CalculateService.
setp three
create an java project, and create an java class named CalculateService, code detail like this
package rong.service;
/**
*
* @author daniel zhou
* 2009-07-22
*/
public class CalculateService {
/**
* plus
* @param x
* @param y
* @return
*/
public float plus( float x, float y) {
return x + y;
}
/**
* minus
* @param x
* @param y
* @return
*/
public float minus( float x, float y) {
return x - y;
}
/**
* multiply
* @param x
* @param y
* @return
*/
public float multiply( float x, float y) {
return x * y;
}
/**
* divide
* @param x
* @param y
* @return
*/
public float divide( float x, float y) {
return x / y;
}
}
/**
*
* @author daniel zhou
* 2009-07-22
*/
public class CalculateService {
/**
* plus
* @param x
* @param y
* @return
*/
public float plus( float x, float y) {
return x + y;
}
/**
* minus
* @param x
* @param y
* @return
*/
public float minus( float x, float y) {
return x - y;
}
/**
* multiply
* @param x
* @param y
* @return
*/
public float multiply( float x, float y) {
return x * y;
}
/**
* divide
* @param x
* @param y
* @return
*/
public float divide( float x, float y) {
return x / y;
}
}
setp four
When service is over, now we will create it as an web service,
select project and new an other, select "web services".
Attention:
- In "Sevice implementation" should locate to your just create java class.
- select your web container (must select runtime to axis2) and select at "start service" point.
- client type selct web container (must select runtime to axis2) and "test client" point
then "next", if you want to create client serive, ok, choose it and next, then all is setting over, start server!
Then you will find in you jboss's deploy dirctory, two ear package have been deployed!
if you intersted in it, can open ear and have a look.
setp five
when server is started, which will open an browser, in which window, it have some test for you to do, like set x=2, and y=33, and click "go" button, the reslut will be show 35 to you!
It cool!
Ok, do by yourself, good luck!
本文转自danni505 51CTO博客,原文链接:http://blog.51cto.com/danni505/181891,如需转载请自行联系原作者