cxf 与spring集成

 

 

 一:在web.xml中增加CXFServlet的配置:

 


	Apache CXF Endpoint
	cxf
	cxf
	org.apache.cxf.transport.servlet.CXFServlet
	1


	cxf
	/services/*

 二:新建applicationContext-cxf.xml,配置endpoint ,url等信息




    
    
    
    

  根据spring contextConfigLocation加载规则,我们把applicationContext-cxf.xml放到classpath:config/context/下。

 
 contextConfigLocation 
 classpath:config/context/applicationContext*.xml 

 

三:测试

@WebService(endpointInterface = "com.easylife.function.sample2.webInterface.IdssWervices")
public class DssWebServicesImpl implements IdssWervices {
	  Map users = new LinkedHashMap();
	  @Autowired
	  ChangeOutInServive changeOutInServive;
      public String sayHi(String text) {
                  return "Hello " + text;
     }

     public String sayHiToUser(User user) {
    	 changeOutInServive.getBomPartCode("");
               users.put(users.size()+1, user);
               return "Hello "+ user.getName();
     }

 

@RequestMapping("/helloworld")
public String test(Model model){
	JaxWsProxyFactoryBean svr = new JaxWsProxyFactoryBean();
        svr.setServiceClass(IdssWervices.class);
        svr.setAddress("http://localhost:8082/easylife/services/idssWervices");
        IdssWervices hw = (IdssWervices) svr.create();
        User user = new User();
        user.setName("textYYh");
        user.setDescription("test");
        String response =  hw.sayHiToUser(user);
        model.addAttribute("msg",response );
        return "webservicetest";
}

 经测试changeOutInServive 已经注入,和spring集成成功。

你可能感兴趣的:(cxf 与spring集成)