1、发布的几种方式
POJO+axis2-war:
这种方式比较适合简单功能,直接写一个POJO,放到axis2-war下的pojo目录即可
AAR+axis2-war:
这种方式比较适合发布,将服务打成aar包,放到axis2-war下的service目录即可
web+axis2:
这种方式比较适合调试,将axis2集成到web工程,个人比较喜欢这个方式
2、Service组成
a、服务类
PersonManager.java
package com.ats.ws; import com.ats.db.Person; import com.ats.db.PersonAddResponse; import com.ats.db.PersonDAO; public class PersonManager { public PersonAddResponse PersonAdd(Person person) { PersonAddResponse rsp = new PersonAddResponse(); //PersonDAO dao = new PersonDAO(); //rsp.setOperationReult(dao.InsertPerson(person)); return rsp; } }
b、服务描述文件
services/Person/META-INF/services.xml
<?xml version="1.0" encoding="UTF-8"?> <service name="PersonManager"> <description>PersonManagere</description> <parameter name="ServiceClass">com.ats.ws.PersonManager</parameter> <operation name="PersonAdd"> <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> </operation> </service>
c、wsdl
可以自动生成,一般不需要指定
3、Axis2集成到WebApp的方式
a、axis2-web拷贝到project/WebContent下
b、conf、modules、services拷贝到project/WebContent/WEB-INF下
c、所需lib,拷贝到project/WebContent/WEB-INF/lib下
c、web.xml增加下面内容:
<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> <servlet-name>AxisAdminServlet</servlet-name> <servlet-class>org.apache.axis2.webapp.AxisAdminServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>AxisServlet</servlet-name> <url-pattern>/servlet/AxisServlet</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>AxisServlet</servlet-name> <url-pattern>*.jws</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>AxisServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>AxisAdminServlet</servlet-name> <url-pattern>/axis2-admin/*</url-pattern> </servlet-mapping>