Axis2与整合Spring
web.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
5 http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
6 version="2.5">
7
8 <display-name>Server</display-name>
9 <listener>
10 <listener-class>org.springframework.web.context.ContextLoaderListener
11 </listener-class>
12 </listener>
13 <context-param>
14 <param-name>contextConfigLocation</param-name>
15 <param-value>/WEB-INF/applicationContext.xml</param-value>
16 </context-param>
17 <servlet>
18 <servlet-name>AxisServlet</servlet-name>
19 <servlet-class>org.apache.axis2.transport.http.AxisServlet
20 </servlet-class>
21 <load-on-startup>1</load-on-startup>
22 </servlet>
23
24 <servlet-mapping>
25 <servlet-name>AxisServlet</servlet-name>
26 <url-pattern>/services/*</url-pattern>
27 </servlet-mapping>
28
29 <welcome-file-list>
30 <welcome-file>index.jsp</welcome-file>
31 <welcome-file>index.html</welcome-file>
32 <welcome-file>/axis2-web/index.jsp</welcome-file>
33 </welcome-file-list>
34
35 </web-app>
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="applicationContext" class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" /> <bean id="springAixsService" class="jp.co.solxyz.transfer.webservice.SpringAixsService"> <property name="loginService" ref="loginService" /> </bean> <bean id="loginService" class="jp.co.solxyz.transfer.webservice.LoginService"></bean> </beans>
services.xml
<?xml version="1.0" encoding="UTF-8"?> <serviceGroup> <service name="SpringAwareService" scope="application"> <description> spring example </description> <schema schemaNamespace="http://solxyz.co.jp" /> <parameter name="ServiceObjectSupplier">org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier </parameter> <parameter name="SpringBeanName">springAixsService</parameter> <messageReceivers> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" /> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> </messageReceivers> </service> </serviceGroup>
SpringAixsService.java
public class SpringAixsService { private LoginService loginService = null; public String login(String uname,String pwd){ return loginService.login(uname, pwd); } public void setLoginService(LoginService loginService) { this.loginService = loginService; } }
LoginService.java
public class LoginService { /** * Check Login By name & password * * @param name * @param password * @return */ public String login(String name, String password) { return "Success!"; } }
作者:很有意思
出处:http://www.cnblogs.com/chen-lei
关于作者:扛过枪,没机会打仗,现为程序员集团军一名现役程序员
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接
如有问题,可以通过chenlei65368@sohu.com 联系我,非常感谢。