CXF的简单配置应用

   声明:本站部分内容来自互联网,如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

21

Server:

     //1.创建发布服务的工厂JaxWsServerFactoryBean factoryBean=new JaxWsServerFactoryBean();//2.设置服务地址factoryBean.setAddress("http://localhost:8888/book");//3.设置服务接口,发布的服务factoryBean.setServiceClass(BookService.class);//4。设置服务实现factoryBean.setServiceBean(new BookServiceImpl());//5.创建服务并启动Server server=factoryBean.create();server.start();

Client:

    //1.代理服务工厂JaxWsProxyFactoryBean factoryBean=new JaxWsProxyFactoryBean();//2.设置portfactoryBean.setAddress("http://localhost:8888/book?wsdl");//3.服务实现factoryBean.setServiceClass(BookService.class);//4.创建客户端BookService service=(BookService)factoryBean.create();

Cxf和SpringMVC整合

server端:

web.xml的配置:

encodingFilterorg.springframework.web.filter.CharacterEncodingFilterencodingUTF-8forceEncodingtrueencodingFilter/*cxforg.apache.cxf.transport.servlet.CXFServletconfig-locationclasspath:spring-cxf.xml1cxf/ws/*

Server端的springmvc配置:



Client端的配置: