http://lengchaotian.iteye.com/blog/1729752

+mybatis+Spring 配置           

CXF的server端配置  首先配置web.xml 

Java代码 复制代码  收藏代码
  1. <servlet>   
  2.         <servlet-name>cxfServlet</servlet-name>  
  3.         <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>   
  4.         <load-on-startup>2</load-on-startup>  
  5.      </servlet>   
  6.      <servlet-mapping>   
  7.         <servlet-name>cxfServlet</servlet-name>   
  8.         <url-pattern>/cxf/*</url-pattern>   
  9.     </servlet-mapping>   
<servlet> 
		<servlet-name>cxfServlet</servlet-name>
		<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> 
		<load-on-startup>2</load-on-startup>
	 </servlet> 
	 <servlet-mapping> 
	 	<servlet-name>cxfServlet</servlet-name> 
		<url-pattern>/cxf/*</url-pattern> 
	</servlet-mapping> 

 applicationContext.xml和myBatisConfig.xml文件都放在了src目录下

其中applicationContext.xml中的配置

Java代码 复制代码  收藏代码
  1. 在配置文件头添加CXF的配置  
  2. xmlns:jaxws="http://cxf.apache.org/jaxws"  
  3. http://cxf.apache.org/jaxws   
  4. http://cxf.apache.org/schemas/jaxws.xsd  
  5.   
  6. 导入CXF的配置文件  
  7.   
  8. <import resource="classpath:META-INF/cxf/cxf.xml" />  
  9.     <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />  
  10.     <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />  
  11.   
  12. <!-- WebService 服务端配置信息 -->  
  13.     <bean id="jsmService" class="com.a.webservice.impl.JsmWebServiceImpl" />  
  14.     <jaxws:endpoint id="getUser" implementor="#jsmService"  
  15.         address="/JsmWeb">  
  16.     </jaxws:endpoint>  
在配置文件头添加CXF的配置
xmlns:jaxws="http://cxf.apache.org/jaxws"
http://cxf.apache.org/jaxws 
http://cxf.apache.org/schemas/jaxws.xsd

导入CXF的配置文件

<import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

<!-- WebService 服务端配置信息 -->
	<bean id="jsmService" class="com.a.webservice.impl.JsmWebServiceImpl" />
	<jaxws:endpoint id="getUser" implementor="#jsmService"
		address="/JsmWeb">
	</jaxws:endpoint>

 

在springmvc-servlet.xml文件中导入applicationContext.xml文件

 

Java代码 复制代码  收藏代码
  1. <import resource="classpath:/applicationContext.xml"/>  
<import resource="classpath:/applicationContext.xml"/>
 

CXF客户端 applicationContext.xml中的配置 :

 

Java代码 复制代码  收藏代码
  1. 在配置文件头添加CXF的配置  
  2. xmlns:jaxws="http://cxf.apache.org/jaxws"  
  3. http://cxf.apache.org/jaxws   
  4. http://cxf.apache.org/schemas/jaxws.xsd  
  5.   
  6. 导入CXF的配置文件  
  7.   
  8. <import resource="classpath:META-INF/cxf/cxf.xml" />  
  9. <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />  
  10. <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />  
  11.   
  12. <!-- WebService 客户端配置信息 -->  
  13.     <jaxws:client id="JsmWebClient" serviceClass="com.blingtel.webservice.JsmWebService"  
  14.         address="http://localhost:8080/SafeManageSystem/cxf/JsmWeb" />  
在配置文件头添加CXF的配置
xmlns:jaxws="http://cxf.apache.org/jaxws"
http://cxf.apache.org/jaxws 
http://cxf.apache.org/schemas/jaxws.xsd

导入CXF的配置文件

<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

<!-- WebService 客户端配置信息 -->
	<jaxws:client id="JsmWebClient" serviceClass="com.blingtel.webservice.JsmWebService"
		address="http://localhost:8080/SafeManageSystem/cxf/JsmWeb" />

 服务器端使用CXF

Java代码 复制代码  收藏代码
  1. @Override  
  2.     public String updateUserState(String userId)  
  3.     {  
  4.         // 初始化userDao  
  5.         UserDao userDao = (UserDao)Global.getObject(UserDao.class);  
  6.           
  7.         // 修改用户在线状态为离线  
  8.         userDao.updateUserState(0, userId);  
  9.           
  10.         return Global.SUCCESS;  
  11.     }  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值