1.打开axis2.war包,将conf,lib,modules三个文件夹复制到项目的WEB-INF文件夹下
2.新建一个services文件夹,然后在services文件下新建一个文件夹(任意取名),再新建META-INF文件夹,最后再新增services.xml,
接口信息就写在这里面。
具体路径:WEB-INF/services/myservice/META-INF/services.xml
3.开发java类
class="java" name="code">
package Axis2Service.service;
/**
* desc:计算俩个数和值的 webservice接口
*
* @version SVN $Revision: 1.1 $ $Date: 2011/07/12 02:06:49 $
*/
public class Calculate {
public Integer sum(Integer num1, Integer num2) {
return num1 + num2;
}
}
4.现在编写services.xml文件
<service name="AxisService">
<description>AxisService</description>
<parameter name="ServiceClass">
Axis2Service.service.Calculate
</parameter>
<operation name="sum">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
</service>
5.修改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-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
6.发布项目,然后在地址栏上输入http://localhost:8080/MyAxis/services/AxisService?wsdl,就能看到发布的项目了哦!!
参考:http://wangronaldo.iteye.com/blog/1456441