锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲精品永久免费视频,一区二区三区四区五区精品视频,av在线播放观看http://www.aygfsteel.com/stevenjohn/category/52438.html閭d簺闈掓槬鐨勫瞾鏈?/description>zh-cnTue, 21 Aug 2012 06:31:25 GMTTue, 21 Aug 2012 06:31:25 GMT60cxf spring闆嗘垚(涓?http://www.aygfsteel.com/stevenjohn/archive/2012/08/21/385936.htmlabinabinTue, 21 Aug 2012 06:20:00 GMThttp://www.aygfsteel.com/stevenjohn/archive/2012/08/21/385936.htmlhttp://www.aygfsteel.com/stevenjohn/comments/385936.htmlhttp://www.aygfsteel.com/stevenjohn/archive/2012/08/21/385936.html#Feedback0http://www.aygfsteel.com/stevenjohn/comments/commentRss/385936.htmlhttp://www.aygfsteel.com/stevenjohn/services/trackbacks/385936.html闃呰鍏ㄦ枃

abin 2012-08-21 14:20 鍙戣〃璇勮
]]>
cxf spring闆嗘垚(浜?http://www.aygfsteel.com/stevenjohn/archive/2012/08/21/385926.htmlabinabinTue, 21 Aug 2012 03:17:00 GMThttp://www.aygfsteel.com/stevenjohn/archive/2012/08/21/385926.htmlhttp://www.aygfsteel.com/stevenjohn/comments/385926.htmlhttp://www.aygfsteel.com/stevenjohn/archive/2012/08/21/385926.html#Feedback0http://www.aygfsteel.com/stevenjohn/comments/commentRss/385926.htmlhttp://www.aygfsteel.com/stevenjohn/services/trackbacks/385926.html浜斻丆XF WebService鏁村悎Spring

棣栧厛錛孋XF鍜宻pring鏁村悎闇瑕佸噯澶囧涓媕ar鍖呮枃浠訛細

image

榪欒竟鎴戞槸鐢⊿pring鐨刯ar鍖呮槸Spring瀹樻柟鎻愪緵鐨勶紝騫舵病鏈変嬌鐢–XF涓殑Spring鐨刯ar鏂囦歡銆?

娣誨姞榪欎箞澶氭枃浠跺悗錛岄鍏堝湪web.xml涓坊鍔犲涓嬮厤緗細

<!-- 鍔犺澆Spring瀹瑰櫒閰嶇疆 -->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 璁劇疆Spring瀹瑰櫒鍔犺澆閰嶇疆鏂囦歡璺緞 -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:applicationContext-server.xml</param-value>
</context-param>
 
<listener>
    <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
 
<servlet>
    <servlet-name>CXFService</servlet-name>
    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
</servlet>
 
<servlet-mapping>
    <servlet-name>CXFService</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

鐒跺悗鍦╯rc鐩綍涓紝鏂板緩涓涓猘pplicationContext-server.xml鏂囦歡錛屾枃浠跺唴瀹瑰涓嬶細

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jaxws="http://cxf.apache.org/jaxws"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans >
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://cxf.apache.org/jaxws 
    http://cxf.apache.org/schemas/jaxws.xsd"

娉ㄦ剰涓婇潰鐨勫甫涓嬪垝綰垮姞綺楅儴鍒嗭紝榪欎釜寰堥噸瑕佺殑鍝︼紒涓嶈兘鍐欓敊鎴栨槸閬楁紡浜嗐?

娣誨姞瀹岃繖涓枃浠跺悗錛岃繕闇瑕佸湪榪欎釜鏂囦歡涓鍏ヨ繖涔堝嚑涓枃浠躲傛枃浠跺唴瀹瑰涓嬶細

<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"/>

涓嬮潰寮濮嬪啓鏈嶅姟鍣ㄧ浠g爜錛岄鍏堝畾鍒舵湇鍔″櫒绔殑鎺ュ彛錛屼唬鐮佸涓嬶細

package com.hoo.service;
 
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import com.hoo.entity.User;
import com.hoo.entity.Users;
 
/**
 * <b>function:</b>瀹氬埗瀹㈡埛绔姹俉ebService鎵闇瑕佺殑鎺ュ彛
 * @author hoojo
 * @createDate 2011-3-18 涓婂崍08:22:55
 * @file ComplexUserService.java
 * @package com.hoo.service
 * @project CXFWebService
 * @blog http://blog.csdn.net/IBM_hoojo
 * @email hoojo_@126.com
 * @version 1.0
 */
@WebService
@SOAPBinding(style = Style.RPC)
public interface IComplexUserService {
    
    public User getUserByName(@WebParam(name = "name") String name);
    
    public void setUser(User user);
}

涓嬮潰緙栧啓WebService鐨勫疄鐜扮被錛屾湇鍔″櫒绔疄鐜頒唬鐮佸涓嬶細

package com.hoo.service;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import com.hoo.entity.User;
import com.hoo.entity.Users;
 
/**
 * <b>function:</b> WebService浼犻掑鏉傚璞★紝濡侸avaBean銆丄rray銆丩ist銆丮ap絳?/span>
 * @author hoojo
 * @createDate 2011-3-18 涓婂崍08:22:55
 * @file ComplexUserService.java
 * @package com.hoo.service
 * @project CXFWebService
 * @blog http://blog.csdn.net/IBM_hoojo
 * @email hoojo_@126.com
 * @version 1.0
 */
@WebService
@SOAPBinding(style = Style.RPC)
@SuppressWarnings("deprecation")
public class ComplexUserService implements IComplexUserService {
    
    public User getUserByName(@WebParam(name = "name") String name) {
        User user = new User();
        user.setId(new Date().getSeconds());
        user.setName(name);
        user.setAddress("china");
        user.setEmail(name + "@hoo.com");
        return user;
    }
    
    public void setUser(User user) {
        System.out.println("############Server setUser###########");
        System.out.println("setUser:" + user);
    }
}

娉ㄦ剰鐨勬槸鍜孲pring闆嗘垚錛岃繖閲屼竴瀹氳瀹屾垚鎺ュ彛瀹炵幇錛屽鏋滄病鏈夋帴鍙g殑璇濅細鏈夐敊璇殑銆?

涓嬮潰瑕佸湪applicationContext-server.xml鏂囦歡涓坊鍔犲涓嬮厤緗細

<bean id="userServiceBean" class="com.hoo.service.ComplexUserService"/>
 
<bean id="inMessageInterceptor" class="com.hoo.interceptor.MessageInterceptor">
    <constructor-arg  value="receive"/>
</bean>
 
<bean id="outLoggingInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
<!-- 娉ㄦ剰涓嬮潰鐨刟ddress錛岃繖閲岀殑address鐨勫悕縐板氨鏄闂殑WebService鐨刵ame -->
<jaxws:server id="userService" serviceClass="com.hoo.service.IComplexUserService" address="/Users">
    <jaxws:serviceBean>
        <!-- 瑕佹毚闇茬殑 bean 鐨勫紩鐢?-->
        <ref bean="userServiceBean"/>
    </jaxws:serviceBean>
    <jaxws:inInterceptors>
        <ref bean="inMessageInterceptor"/>
    </jaxws:inInterceptors>
    <jaxws:outInterceptors>
        <ref bean="outLoggingInterceptor"/>
    </jaxws:outInterceptors>
</jaxws:server>

涓嬮潰鍚姩tomcat鏈嶅姟鍣ㄥ悗錛屽湪WebBrowser涓姹傦細

http://localhost:8080/CXFWebService/Users?wsdl

濡傛灉浣犺兘鐪嬪埌wsdl鐨剎ml鏂囦歡鐨勫唴瀹癸紝灝辮鏄庝綘鎴愬姛浜嗭紝娉ㄦ剰鐨勬槸涓婇潰鍦板潃鐨刄sers灝辨槸涓婇潰xml閰嶇疆涓殑address鐨勫悕縐幫紝鏄竴涓瀵瑰簲鐨勩?

涓嬮潰緙栧啓瀹㈡埛绔姹傜殑浠g爜錛屼唬鐮佸涓嬶細

package com.hoo.client;
 
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import com.hoo.entity.User;
import com.hoo.service.IComplexUserService;
 
/**
 * <b>function:</b>璇鋒眰Spring鏁村悎CXF鐨刉ebService瀹㈡埛绔?/span>
 * @author hoojo
 * @createDate 2011-3-28 涓嬪崍03:20:35
 * @file SpringUsersWsClient.java
 * @package com.hoo.client
 * @project CXFWebService
 * @blog http://blog.csdn.net/IBM_hoojo
 * @email hoojo_@126.com
 * @version 1.0
 */
public class SpringUsersWsClient {
 
    public static void main(String[] args) {
        //璋冪敤WebService
        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
        factory.setServiceClass(IComplexUserService.class);
        factory.setAddress("http://localhost:8080/CXFWebService/Users");
        
        IComplexUserService service = (IComplexUserService) factory.create();
        
        System.out.println("#############Client getUserByName##############");
        User user = service.getUserByName("hoojo");
        System.out.println(user);
        
        user.setAddress("China-Guangzhou");
        service.setUser(user);
    }
}

榪愯鍚庯紝鍙互鍦ㄦ帶鍒跺彴涓湅鍒?/p>

log4j:WARN No appenders could be found for logger (org.apache.cxf.bus.spring.BusApplicationContext).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
2011-3-28 18:12:26 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
淇℃伅: Creating Service {http://service.hoo.com/}IComplexUserServiceService from class com.hoo.service.IComplexUserService
#############Client getUserByName##############
27#hoojo#hoojo@hoo.com#china

Tomcat鎺у埗鍙?
 image 

榪欎釜server绔槸閫氳繃Spring鏁村悎閰嶇疆鐨勶紝涓嬮潰鎴戜滑灝咰lient绔篃閫氳繃Spring閰嶇疆瀹屾垚鏁村悎銆?

棣栧厛澧炲姞applicationContext-client.xml閰嶇疆鏂囦歡錛屾枃浠跺唴瀹瑰涓嬶細

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jaxws="http://cxf.apache.org/jaxws"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans >
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://cxf.apache.org/jaxws 
    http://cxf.apache.org/schemas/jaxws.xsd"
    
    <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"/>
    
    <jaxws:client id="userWsClient" serviceClass="com.hoo.service.IComplexUserService" 
        address="http://localhost:8080/CXFWebService/Users"/>
</beans>

瀹㈡埛绔姹備唬鐮佸涓嬶細

package com.hoo.client;
 
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.hoo.entity.User;
import com.hoo.service.IComplexUserService;
 
/**
 * <b>function:</b>璇鋒眰Spring鏁村悎CXF鐨刉ebService瀹㈡埛绔?/span>
 * @author hoojo
 * @createDate 2011-3-28 涓嬪崍03:20:35
 * @file SpringUsersWsClient.java
 * @package com.hoo.client
 * @project CXFWebService
 * @blog http://blog.csdn.net/IBM_hoojo
 * @email hoojo_@126.com
 * @version 1.0
 */
public class SpringUsersWsClient {
 
    public static void main(String[] args) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext-client.xml");
        
        IComplexUserService service = ctx.getBean("userWsClient", IComplexUserService.class);
        
        System.out.println("#############Client getUserByName##############");
        User user = service.getUserByName("hoojo");
        System.out.println(user);
        
        user.setAddress("China-Guangzhou");
        service.setUser(user);
    }
}

榪愯鍚庣粨鏋滃涓嬶細

#############Client getUserByName##############
45#hoojo#hoojo@hoo.com#china
############Server setUser###########
setUser:45#hoojo#hoojo@hoo.com#China-Guangzhou

浣滆咃細hoojo
鍑哄錛?a target="_blank">

http://www.cnblogs.com/hoojo/archive/2011/03/30/1999563.html
blog錛?a target="_blank">http://blog.csdn.net/IBM_hoojo
鏈枃鐗堟潈褰掍綔鑰呭拰鍗氬鍥叡鏈夛紝嬈㈣繋杞澆錛屼絾鏈粡浣滆呭悓鎰忓繀欏諱繚鐣欐孌靛0鏄庯紝涓斿湪鏂囩珷欏甸潰鏄庢樉浣嶇疆緇欏嚭鍘熸枃榪炴帴錛屽惁鍒欎繚鐣欒拷絀舵硶寰嬭矗浠葷殑鏉冨埄銆?

 


鐗堟潈鎵鏈夛紝杞澆璇鋒敞鏄庡嚭澶?/a> 鏈枃鍑鴻嚜錛?http://www.cnblogs.com/hoojo/archive/2011/03/30/1999563.html


abin 2012-08-21 11:17 鍙戣〃璇勮
]]>
cxf spring闆嗘垚(涓)http://www.aygfsteel.com/stevenjohn/archive/2012/08/21/385896.htmlabinabinMon, 20 Aug 2012 16:27:00 GMThttp://www.aygfsteel.com/stevenjohn/archive/2012/08/21/385896.htmlhttp://www.aygfsteel.com/stevenjohn/comments/385896.htmlhttp://www.aygfsteel.com/stevenjohn/archive/2012/08/21/385896.html#Feedback0http://www.aygfsteel.com/stevenjohn/comments/commentRss/385896.htmlhttp://www.aygfsteel.com/stevenjohn/services/trackbacks/385896.html/**
 *
 */
package com.abin.lee.cxf;

import javax.jws.WebService;

/**
 * @author abin
 *
 */
@WebService(targetNamespace="cxf.lee.abin.com")
public interface IUserService {
 public String getMessage(String message);
}





package com.abin.lee.cxf;

import javax.jws.WebService;

@WebService(endpointInterface="com.abin.lee.cxf.IUserService")
public class UserService implements IUserService{

 public String getMessage(String message) {
  return message+" welcome to beijing";
 }
 
}






<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=" xmlns:xsi=" xmlns:tx=" xmlns:jaxws=" xmlns:cxf=" xmlns:wsa=" xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 http://www.springframework.org/schema/tx
 http://www.springframework.org/schema/tx/spring-beans-3.0.xsd
 http://cxf.apache.org/core
 http://cxf.apache.org/schemas/core.xsd
 http://cxf.apache.org/jaxws
 http://cxf.apache.org/schemas/jaxws.xsd
 http://www.springframework.org/schema/aop
 http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
 http://www.springframework.org/schema/context
  <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" />
 
 <cxf:bus>
  <cxf:features>
   <!--鏃ュ織鎷︽埅鍔熻兘錛岀敤浜庣洃鎺oap鍐呭錛屽紑鍙戝悗鍙互鍒犻櫎 -->
   <cxf:logging/>
   <wsa:addressing/>
  </cxf:features>
 </cxf:bus> 

 <bean id="userService" class="com.abin.lee.cxf.UserService"></bean>
 <jaxws:endpoint id="userWebservice" implementor="#userService" address="/UserService" publish="true" />


</beans>

 





<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>
   <!--
     classpath*:com/abin/lee/spring/queue/applicationContext-springqueue.xml,
     classpath*:com/abin/lee/quartz/applicationContext-quartzCluster.xml,
     classpath*:com/abin/lee/quartz/applicationContext-quartzHeartCluster.xml,
     classpath*:com/abin/lee/quartz/applicationContext-activemq.xml
   -->
   classpath*:com/abin/lee/cxf/applicationContext-cxf.xml
  </param-value>
 </context-param>
 <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>
 <!--cxf鏈嶅姟鍚姩servlet-->
 <servlet>   
  <servlet-name>CXFServlet</servlet-name>   
  <servlet-class>   
            org.apache.cxf.transport.servlet.CXFServlet    
  </servlet-class>   
  <load-on-startup>1</load-on-startup>   
 </servlet>   
 <servlet-mapping>   
  <servlet-name>CXFServlet</servlet-name>   
  <url-pattern>/service/*</url-pattern>   
 </servlet-mapping> 






package com.abin.lee.spring;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 * 鑾峰彇spring瀹瑰櫒錛屼互璁塊棶瀹瑰櫒涓畾涔夌殑鍏朵粬bean
 *
 * @author lyltiger
 * @since MOSTsView 3.0 2009-11-16
 */
public class SpringContextUtil implements ApplicationContextAware {

 // Spring搴旂敤涓婁笅鏂囩幆澧?br /> private static ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
   "com/abin/lee/cxf/applicationContext-cxf.xml");

 /**
  * 瀹炵幇ApplicationContextAware鎺ュ彛鐨勫洖璋冩柟娉曪紝璁劇疆涓婁笅鏂囩幆澧?br />  *
  * @param applicationContext
  */
 public void setApplicationContext(ApplicationContext applicationContext) {
  SpringContextUtil.applicationContext = applicationContext;
 }

 /**
  * @return ApplicationContext
  */
 public static ApplicationContext getApplicationContext() {
  return applicationContext;
 }

 /**
  * 鑾峰彇瀵硅薄 榪欓噷閲嶅啓浜哹ean鏂規(guī)硶錛岃搗涓昏浣滅敤
  *
  * @param name
  * @return Object 涓涓互鎵緇欏悕瀛楁敞鍐岀殑bean鐨勫疄渚?br />  * @throws BeansException
  */
 public static Object getBean(String name) throws BeansException {
  return applicationContext.getBean(name);
 }

}









package com.abin.lee.cxf.test;

import com.abin.lee.cxf.UserService;
import com.abin.lee.spring.SpringContextUtil;

import junit.framework.TestCase;

public class TestUserService extends TestCase{
 public void testcxf(){
  UserService userService=(UserService)SpringContextUtil.getBean("userService");
  
  String response=userService.getMessage("abin");
  System.out.println("response="+response);
  System.exit(0);
 }
}




abin 2012-08-21 00:27 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 靖安县| 南漳县| 大连市| 霍邱县| 依兰县| 于田县| 佛冈县| 万荣县| 东海县| 佛山市| 息烽县| 自贡市| 周至县| 绩溪县| 彩票| 潮安县| 中山市| 荔波县| 罗甸县| 枞阳县| 张北县| 东兰县| 额尔古纳市| 德州市| 涿州市| 思南县| 木兰县| 商丘市| 天峻县| 桐乡市| 揭西县| 托克逊县| 南宫市| 山阳县| 关岭| 安国市| 和硕县| 象州县| 屏东县| 长武县| 布拖县|