CXF-HelloWorld-Java first
来源:互联网 发布:java昵称自动生成器 编辑:程序博客网 时间:2024/06/15 02:21
1.eclipse中新建java工程,导入cxf包
接口HelloWorld
public interface HelloWorld {
public String sayHi();
}
接口实现HelloWorldImpl
public class HelloWorldImpl implements HelloWorld {
public String sayHi() {
// TODO Auto-generated method stub
return "Hi";
}
}
Server类
import org.apache.cxf.frontend.ServerFactoryBean;
public class Server {
protected Server() throws Exception {
HelloWorldImpl helloworldImpl = new HelloWorldImpl();
ServerFactoryBean svrFactory = new ServerFactoryBean();
svrFactory.setServiceClass(HelloWorld.class);
svrFactory.setAddress("http://localhost:9000/Hello");
svrFactory.setServiceBean(helloworldImpl);
svrFactory.create(); //启动服务
}
public static void main(String args[]) throws Exception {
new Server();
System.out.println("Server ready...");
Thread.sleep(5 * 60 * 1000);
System.out.println("Server exiting");
System.exit(0);
}
}
Client类
import org.apache.cxf.frontend.ClientProxyFactoryBean;
public class Client {
private Client() {
}
public static void main(String args[]) {
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
factory.setServiceClass(HelloWorld.class);
if (args != null && args.length > 0 && !"".equals(args[0])) {
factory.setAddress(args[0]);
} else {
factory.setAddress("http://localhost:9000/Hello");
}
HelloWorld client = (HelloWorld) factory.create();
System.out.println("Invoke sayHi()....");
System.out.println(client.sayHi());
System.exit(0);
}
}
运行server类后 访问http://localhost:9000/Hello能看到wsdl
运行client类
- CXF-HelloWorld-Java first
- CXF-HelloWorld-Java first 使用注释方式
- CXF-HelloWorld2-Java first
- CXF 开发webService的步骤(java First)
- CXF客户端调用--HelloWorld!
- CXF-HelloWorld-服务端
- CXF客户端调用--HelloWorld!
- WebService CXF学习:HelloWorld
- Apache CXF 之HelloWorld
- IDEA8实战-CXF版HelloWorld
- CXF 入门:HelloWorld接口发布
- Apache CXF 第一篇:HelloWorld
- cxf之HelloWorld版本实例
- CXF学习-开篇HelloWorld SERVICE
- cxf+web service(三)HelloWorld
- Head First WebService with CXF
- CXF之从java first开始开发的java代码实例
- java调用基于SOAP的CXF 框架的WebService客户端和服务器段helloworld例子
- 分配和释放 BSTR 的内存
- 人生不可免的缺憾,你怎样面对呢?
- css中SPAN和DIV,Class与ID的区别汇总
- linux的配置文件
- 日期下拉选择器,可自定义日期范围。
- CXF-HelloWorld-Java first
- MTK中的哈希表的资料
- 很有意思的网络通信例子---小明与电话
- linux命令速查和常用命令说明
- HTMLParser使用详解(1)- 初始化Parser
- MySQL 字段排序如何按中文首字母排序
- C#与Vb循环的区别
- 图片上传时,本地显示预览功能
- 4个跨浏览器必备的函数