首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

cxf 公布多个接口的方法

2013-11-29 
cxf 发布多个接口的方法1、使用cxf 中的 JaxWsServerFactoryBean类发布webservicepackage serverimport or

cxf 发布多个接口的方法

1、使用cxf 中的 JaxWsServerFactoryBean类发布webservice

package server;import org.apache.cxf.jaxws.JaxWsServerFactoryBean;import hb.HelloWorldService;import hb.IHelloWorldService;import hb.ISessionSendMsg;import hb.SessionSendMsg;public class Server1 {public static void main(String[] args) {HelloWorldService helloworldimp = new HelloWorldService();JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean();factoryBean.setAddress("http://localhost:8080/WSCXF/helloService");factoryBean.setServiceClass(IHelloWorldService.class);//接口类factoryBean.setServiceBean(helloworldimp);factoryBean.create();JaxWsServerFactoryBean factoryBean1 = new JaxWsServerFactoryBean();SessionSendMsg sessionSendMsg = new SessionSendMsg();factoryBean1.setAddress("http://localhost:8080/WSCXF/sessionService");factoryBean1.setServiceClass(ISessionSendMsg.class);//接口类factoryBean1.setServiceBean(sessionSendMsg);factoryBean1.create();}}

?

?备注:实际上是创建了多个JaxWsServerFactoryBean对象来实现发布多个接口

?

2、使用java原生代码发布webservice

package server;import hb.HelloWorldService;import hb.SessionSendMsg;import javax.xml.ws.Endpoint;public class DeployHelloWorldService {public static void main(String[] args)  {System.out.println("Server start ……");HelloWorldService service = new HelloWorldService();String address = "http://localhost:9000/helloWorld";Endpoint.publish(address, service);SessionSendMsg sessionSendMsg = new SessionSendMsg();String address1 = "http://localhost:9000/session";Endpoint.publish(address1, sessionSendMsg);}}

?

备注:实际上是Endpoint发布多次实现发布多个接口。

热点排行