您的位置:首页 > 其它

cxf ServerFactoryBean 生成基于soap1.2的WebServices

2016-05-10 16:01 405 查看
//获得服务工厂bean
ServerFactoryBean bean = new ServerFactoryBean();

HTTPTransportFactory httpTransportFactory = new HTTPTransportFactory();
//绑定服务的发布地址
bean.setAddress("http://10.0.1.32:5678/hello");
//指定提供服务的类型
bean.setServiceClass(HelloService.class);
//指定提供服务的实例
bean.setServiceBean(new HelloServiceImpl());

bean.getServiceFactory().getConfigurations().add(new MethodNameSoapActionServiceConfiguration());

SoapBindingConfiguration conf = new SoapBindingConfiguration();
conf.setVersion(Soap12.getInstance());
bean.setBindingConfig(conf);

//启动服务-----publish
bean.setStart(false);
ServerImpl server= (ServerImpl)bean.create();
EndpointInfo e1=((ServletDestination)server.getDestination()).getEndpointInfo();

e1.getBinding().getOperations().forEach(e->{

});

Bus b1=((ServletDestination)server.getDestination()).getBus();
Destination destination= httpTransportFactory.getDestination(e1,b1);
server.setDestination(destination);
server.start();

System.out.println("server ready...");


重点代码是

SoapBindingConfiguration conf = new SoapBindingConfiguration();
conf.setVersion(Soap12.getInstance());
bean.setBindingConfig(conf);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: