首页 > Web开发 > 详细

cxf CXF搭建webService服务器

时间:2017-07-15 18:25:58      阅读:329      评论:0      收藏:0      [点我收藏+]

http://observer.blog.51cto.com/4267416/1231205

手动发布:

public class ServerMain {

public static void main(String[] args) {
GradeService service = new GradeServiceImpl();
Endpoint.publish("http://localhost/webservices/services/Service", service);
}
}

客户端调用

package com.test.service;

public class ClientMain {

public static void main(String[] args) throws Exception {
GradeService_Service service = new GradeService_Service();
GradeService gradeServiceImplPort = service.getGradeServicePort();
System.out.println(gradeServiceImplPort.getGradeName(111));


//JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance();

//Client client = clientFactory.createClient("http://localhost/webservices/services/Service?wsdl");

//Object[] result = client.invoke("getGradeName", 11);

//System.out.println(result[0]);
}
}

使用wsdl2java 生成的代码,运行时出现错误,删除包xfire-all-1.2.6可以运行了,实际不用导入任何包就可以运行。

注:wsdl2java 在 apache-cxf-3.1.12 的bin目录下面

cxf CXF搭建webService服务器

原文:http://www.cnblogs.com/newlangwen/p/7183731.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!