Maven搭建webService (三) 创建客户端---使用Apache CXF方式实现

时间:2023-03-09 04:19:10
Maven搭建webService (三) 创建客户端---使用Apache CXF方式实现
 package test;

 import net.cc.web.server.HelloWorld;

 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;

 /**
* @author test
* @create 2014-3-11上午11:26:13
* @version 1.0
*/
public class HelloClient { public static void main(String[] args) { // 创建代理工厂
JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean(); // 设置代理工厂属性(服务类以及地址)
factoryBean.setServiceClass(HelloWorld.class);
factoryBean.setAddress("http://192.168.2.10:9980/Hello"); // 调用
HelloWorld helloWorld = (HelloWorld) factoryBean.create();
System.out.println(helloWorld.sayHello("测试")); }
}