Axis2 Web Service
有一个最简单的方法就是把axis2.war中的内容作为web app的基础, 来进行开发. 不过为了更清楚的了解如何在一个已有的web app中嵌入axis2, 那就只能手动了. 1. 把以下内容copy到已有的web app中 axis2.war/axis2-web axis2.war/WEB-INF/* 2. 在web.xml中配置axis2 servlet Apache-Axis Servlet AxisServlet org.apache.axis2.transport.http.AxisServlet 1 AxisServlet /services/* 3. 创建自己的Service Bean package example; public class HelloWorldService { public HelloWorldService() { } public String hello() { return "Hello axis2 service!"; } } 4. 配置Web Service. 由于axis2嵌入了web app, 所以web service就不用打包成aar,而是直接在/WEB-INF目录下创建相应的文件夹和services.xml /WEB-INF /services /HelloWorld /META-INF services.xml 5. 配置services.xml的内容 Hello World Service example.HelloWorldService 6. 测试 如果一切OK的话, 在浏览器中输入http://localhost:8080/example/services/HelloWorldService?wsdl就应该可以看到输出的wsdl xml. Done! 其实在项目中还集成了Spring, 不过这个应该相对简单. 1. 需要把Spring的jar放到/WEB-INF/lib中 2. services.xml中service的ServiceObjectSupplier用org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier HelloWorldSpringService.java package example; public class HelloWorldSpringService { public String hello() { return "Hello spring axis2 service!"; } } In services.xml: Hello World Service example.HelloWorldService Hello World Spring Service org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier HelloWorldSpringService In applicationContext.xml 参考: How to Embed an Axis2 based Web Service in your Webapp? | WSO2 Oxygen Tank wso2.org/library/90 Axis2 Integration with the Spring Framework http://ws.apache.org/axis2/1_3/spring.html 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/bruni/archive/2008/03/17/2193060.aspx