网上教程不少,每一个人具体状况不一样,我是须要在eclipse下用axis2和hibernate, 本身动手,并记录过程。html
1,下载准备java
eclipse下载web
hibernate eclipse工具apache
axis2:app
axis2-eclipse-codegen-plugin-1.6.2 eclipse
axis2-eclipse-service-plugin-1.6.2 工具
2,axis原理测试
axis2经过客户端和服务端 发送接收soap协议,http+xml,完成消息处理。soap协议是xml的子集,全称是Simple Object Access Protocol。
ui
web serivice消息生命周期url
3,配置部署
axis2启动方式是在web.xml文件中添加servlet和servlet-mapping,和struts同样..其实web都是这样
<!--Axis2 config start--> <servlet> <servlet-name>AxisServlet</servlet-name> <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>AxisServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping> <!--Axis2 end-->
把hibernate eclipse压缩包,axis2压缩包放到eclipse dropin目录下解压缩,启动eclipse,
视图中有hibernate工具表示hibernate插件安装成功:
file-new-other-对方框中有axis2表明axis2插件安装成功
4,代码开发
新建java工程(若是仅用于生成aar文件,则不须要使用web工程),新建测试类
package test; public class TestWS { public String sayHello(String str) { return "say "+str; } }
5,生成服务端aar文件
new-other-axis2 serivce Archiver
skip wsdl
生成aar,放在axis2war包service目录下,服务端部署完毕
get访问:http://localhost:8080/Axis2/services/AxisService/showName?name=aaa&password=bbb
访问控制:可以使用iptable或者过滤器进行访问控制:http://blog.chinaunix.net/uid-20478213-id-1942011.html
参考:http://feiyeguohai.iteye.com/blog/1575700