1.sample 实例之一---java_first_pojo
服务端发布服务的方法:
客户度调用的方法:
//创建服务代理工程bean ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); //设置服务代理地址 factory.setAddress("http://localhost:9000/Hello"); //创建代理服务 HelloWorld client = factory.create(HelloWorld.class); //调用代理服务 System.out.println(client.sayHi(System.getProperty("user.name")));
2.sample实例之二---java_first_jaxws
服务端发布服务的方法:
HelloWorldImpl implementor = new HelloWorldImpl(); String address = "http://localhost:9000/helloWorld"; Endpoint.publish(address, implementor);
客户端调用的方法:
private static final QName SERVICE_NAME = new QName("http://server.hw.demo/", "HelloWorld"); private static final QName PORT_NAME = new QName("http://server.hw.demo/", "HelloWorldPort"); Service service = Service.create(SERVICE_NAME); // Endpoint Address String endpointAddress = "http://localhost:9000/helloWorld"; // If web service deployed on Tomcat deployment, endpoint should be changed to: // String endpointAddress = "http://localhost:8080/java_first_jaxws/services/hello_world"; // Add a port to the Service service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress); HelloWorld hw = service.getPort(HelloWorld.class);
3. sample实例之---java_first_jaxws_factory_bean
服务端发布服务的方法:
private static final QName SERVICE_NAME = new QName("http://server.hw.demo/", "HelloWorld"); private static final QName PORT_NAME = new QName("http://server.hw.demo/", "HelloWorldPort"); Service service = Service.create(SERVICE_NAME); // Endpoint Address String endpointAddress = "http://localhost:9000/helloWorld"; // If web service deployed on Tomcat deployment, endpoint should be changed to: // String endpointAddress = "http://localhost:8080/java_first_jaxws/services/hello_world"; // Add a port to the Service service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress); HelloWorld hw = service.getPort(HelloWorld.class);
客户端调用的方法:
HelloWorldImpl implementor = new HelloWorldImpl(); JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean(); svrFactory.setServiceClass(HelloWorld.class); svrFactory.setAddress("http://localhost:9000/helloWorld"); svrFactory.setServiceBean(implementor); svrFactory.getInInterceptors().add(new LoggingInInterceptor()); svrFactory.getOutInterceptors().add(new LoggingOutInterceptor()); svrFactory.create();
4.sample实例之一---java_first_spring_support
服务端发布服务
客户度调用服务:
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"client-beans.xml"}); HelloWorld client = (HelloWorld)context.getBean("client"); String response = client.sayHi("Joe");
客户度调用小结
(引用http://blog.csdn.net/liaomin416100569/article/details/5503410)
UserServiceImplService serivce = new UserServiceImplService(); UserServiceImpl impl = serivce.getUserServiceImplPort();
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setAddress("http://localhost:8088/abc"); QName SERVICE = new QName("http://liaomin", "UserServiceImplService"); factory.setServiceName(SERVICE); factory.setServiceClass(UserService.class); UserService us = (UserService) factory.create();
QName SERVICE = new QName("http://liaomin", "UserServiceImplService"); QName UserServiceImplPort = new QName("http://liaomin", "UserServiceImplPort"); URL url = new URL("http://localhost:8088/abc?wsdl"); ServiceDelegate dele=Provider.provider().createServiceDelegate(url,SERVICE,Service.class); UserService us = (UserService) dele.getPort(UserServiceImplPort,UserService.class);
ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.setServiceClass(UserService.class); factory.setAddress("http://localhost:8088/abc"); // factory.getServiceFactory().setDataBinding(new AegisDatabinding()); UserService client = (UserService) factory.create();
相关推荐
CXF开发实例.pdf
CXF实例源代码 客户端调用 web service 入门教程
webservice天气预报例子cxf实例,
CXF实例源代码(服务器端) 入门教程 webservice 实例
一个用springboot搭建的简单的cxf实例,可以用于入门跟学习
CXF实例以及全面讲解(附带开发工具包:part1、part2、part3)请大家分别下载
webservice之cxf实例............
Spring集成CXF实例(包含WSS4J安全认证)
Spring CXF Restful 实例
CXF开发实例.CXF开发实例.CXF开发实例.CXF开发实例.CXF开发实例.CXF开发实例.
cxf spring maven 实例 webservice
myeclipse环境下Spring集成开发CXF实例,由于容量限制,相关的JAR没有上传,请大家自己到相关网站下载...
关联博客: http://blog.csdn.net/yongaini10/article/details/52253463
NULL 博文链接:https://zw7534313.iteye.com/blog/2250409
用java写的使用cxf开发websever
CXF实例以及全面讲解(附带开发工具包:part1、part2、part3)请大家分别下载
CXF实例以及全面讲解(附带开发工具包:part1、part2、part3)请大家分别下载
springmvc+webservice(cxf)+maven 完整实例,下载直接可以运行,非常实用
CXF 实例 可以运行。本人自己写的,希望对大家有用
cxf开发webservice简单实例:包括服务端与客户端并所有需要的jar,不要分啦。