使用CXF 开发WebService 客户端
@WebService
public interface HelloWorld {
public String say(String str);
}
@WebService
public class HelloWorldImpl implements HelloWorld {
public String say(String str) {
return "你好!"+str;
}
}
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
public class Server {
public static void main(String[] args) {
System.out.println("web service 启动...");
String address = "http://192.168.1.102/helloworld";
//Endpoint.publish(address, new HelloWorldImpl()); // jdk实现 暴露webservice接口
JaxWsServerFactoryBean factoryBean=new JaxWsServerFactoryBean();
factoryBean.setAddress(address); // 设置暴露地址
factoryBean.setServiceClass(HelloWorld.class); // 接口类
factoryBean.setServiceBean(new HelloWorldImpl()); // 设置实现类
factoryBean.create(); // 创建webservice接口
System.out.println("web service started");
}
http://192.168.1.102/helloworld?wsdl
}