Maven搭建webService (三) 创建客户端---使用Apache CXF方式实现
1 package test; 2 3 import net.cc.web.server.HelloWorld; 4 5 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; 6 7 /** 8 * @author test 9 * @create 2014-3-11上午11:26:13 10 * @version 1.0 11 */ 12 public class HelloClient { 13 14 public static void main(String[] args) { 15 16 // 创建代理工厂 17 JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean(); 18 19 // 设置代理工厂属性(服务类以及地址) 20 factoryBean.setServiceClass(HelloWorld.class); 21 factoryBean.setAddress("http://192.168.2.10:9980/Hello"); 22 23 // 调用 24 HelloWorld helloWorld = (HelloWorld) factoryBean.create(); 25 System.out.println(helloWorld.sayHello("测试")); 26 27 } 28 }