cxf ServerFactoryBean 生成基于soap1.2的WebServices
//获得服务工厂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);
如果我的文章对你有帮助,就点一下推荐吧.(*^__^*)