CXF 动态创建客户端调用稳定版本号为2.7.18
今天用动态创建客户端的方式调用webservice,报了这样一个错:
2017-01-05 20:51:46,029 DEBUG main org.apache.cxf.common.logging.LogUtils - Using org.apache.cxf.common.logging.Log4jLogger for logging.
2017-01-05 20:51:46,168 DEBUG main org.apache.cxf.endpoint.dynamic.DynamicClientFactory - Creating client from WSDL http://localhost/sdas/webService/TestWebservice?wsdl
2017-01-05 20:51:46,274 DEBUG main org.apache.cxf.transport.http.HTTPConduit - Conduit '{http://cxf.apache.org}TransportURIResolver.http-conduit' has been (re)configured for plain http.
2017-01-05 20:51:46,274 DEBUG main org.apache.cxf.transport.http.HTTPConduit - No Trust Decider configured for Conduit '{http://cxf.apache.org}TransportURIResolver.http-conduit'
2017-01-05 20:51:46,274 DEBUG main org.apache.cxf.transport.http.HTTPConduit - No Auth Supplier configured for Conduit '{http://cxf.apache.org}TransportURIResolver.http-conduit'
2017-01-05 20:51:46,274 DEBUG main org.apache.cxf.transport.http.HTTPConduit - Conduit '{http://cxf.apache.org}TransportURIResolver.http-conduit' has been configured for plain http.
2017-01-05 20:51:46,277 DEBUG main org.apache.cxf.transport.http.HTTPConduit - registering incoming observer: org.apache.cxf.transport.TransportURIResolver$1@6165e7a5
2017-01-05 20:51:46,292 DEBUG main org.apache.cxf.transport.http.Headers - Accept: */*
2017-01-05 20:51:46,294 DEBUG main org.apache.cxf.transport.http.TrustDecisionUtil - No Trust Decider for Conduit '{http://cxf.apache.org}TransportURIResolver.http-conduit'. An afirmative Trust Decision is assumed.
2017-01-05 20:51:46,481 DEBUG main org.apache.cxf.transport.http.HTTPConduit - Response Code: 200 Conduit: {http://cxf.apache.org}TransportURIResolver.http-conduit
2017-01-05 20:51:46,481 DEBUG main org.apache.cxf.transport.http.HTTPConduit - Content length: -1
2017-01-05 20:51:46,481 DEBUG main org.apache.cxf.transport.http.HTTPConduit - Header fields:
null: [HTTP/1.1 200 OK]
Date: [Thu, 05 Jan 2017 12:51:46 GMT]
Transfer-Encoding: [chunked]
Content-Type: [text/xml]
Server: [Apache-Coyote/1.1] Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy15.bind(Unknown Source)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:318)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:235)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:228)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:183)
at platform.AnotherWSTest.main(AnotherWSTest.java:12)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.cxf.common.util.ReflectionInvokationHandler.invoke(ReflectionInvokationHandler.java:53)
... 6 more
Caused by: java.lang.NoSuchFieldError: theInstance
at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.<init>(BGMBuilder.java:165)
at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:112)
at com.sun.tools.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:415)
at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:246)
... 11 more
服务端是没有问题的,用url调用可以正常执行。
最后通过更改我们的CXF版本解决了这个问题:
之前的版本:2.6.2
修改后的版本:2.7.18,试了用3.X.X表示不行
因为是用的maven所以该版本比较方便,如下:
常量
<properties>
<cxf.version>2.7.18</cxf.version>
</properties>
dependency
<!-- CXF WEBSERVICE -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<!-- CXF WEBSERVICE END -->
服务端和客户端最好统一,如果只改客户端(cxf-rt-frontend-jaxws)为2.7.18也是可以的
最后附一个动态调用示例写法:
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; import com.alibaba.fastjson.JSON; import javax.xml.bind.*; /**
* @ClassName: WebServiceTest
* @Description: TODO
* @author: liuyx
* @date: 2015年9月27日下午5:22:15
*/
public class WebServiceTest {
private static final String testUrl = "http://172.16.10.87/platform3.0/webService/TestWebservice?wsdl";
public static void main(String[] args) throws Exception {
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient(testUrl); Object[] objects=client.invoke("testOut", "test");
//输出调用结果
System.out.println(JSON.toJSONString(objects));
}
}
CXF 动态创建客户端调用稳定版本号为2.7.18的更多相关文章
- CXF 调用方式——动态创建客户端(调用稳定版本号为2.7.18)
今天用动态创建客户端的方式调用webservice,报了这样一个错: 2017-01-05 20:51:46,029 DEBUG main org.apache.cxf.common.logging. ...
- cxf 动态创建客户端,局域网能正常调用服务端,外网不能访问
- cxf 和 httpclient 客户端调用 webservice 接口
一.cxf 生成 webservice 客户端 1.接口路径 http://ws.webxml.com.cn/WebServices/WeatherWS.asmx 2.进入你需要放置 webservi ...
- firedac的TFDStoredProc动态创建并调用存储过程
1)中间件执行存储过程 sp.Close; sp.StoredProcName := procName; sp.Prepare; // 生成存储过程的参数列表,无任何OUTPUT的存储过程,也会自动 ...
- CXF动态客户端如何优化JaxWsDynamicClientFactory.createClient -- 慢
在CXF动态创建客户端时,如下: JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance(); Client ...
- axis1客户端调用webservice的通用代码
1.axis1 作为web service 客户端时,调用web service 服务端的通用代码 String url = "http://www.webxml.com.cn/webser ...
- 对xxl-job进行simpleTrigger并动态创建任务扩展
业务场景 需求上要求能实现quartz的simpleTrigger任务,同时还需要动态的创建任务而非在控制面板上创建,查阅xxl-job官方文档发现simpelTrigger其暂时还躺在to do l ...
- WebService—CXF—实现接口发布和客户端调用
(一)接口发布的几种方式 定义接口: @WebService(targetNamespace="http://www.itfad.net/queryUser") public in ...
- CXF发布webService服务以及客户端调用
这篇随笔内容是CXF发布webService服务以及客户端调用的方法 CXF是什么? 开发工作之前需要下载CXF和安装 下载地址:http://cxf.apache.org 安装过程: <1&g ...
随机推荐
- 【PHP资源】PHP 资源大全
看到这篇文章不错,转来收藏 依赖管理 依赖和包管理库 Composer/Packagist:一个包和依赖管理器 Composer Installers:一个多框架Composer库安装器 Pickle ...
- Code First :使用Entity. Framework编程(6) ----转发 收藏
Chapter6 Controlling Database Location,Creation Process, and Seed Data 第6章 控制数据库位置,创建过程和种子数据 In prev ...
- 足球宝贝来了,任你旋转(CSS3)
点击这里体验效果:http://keleyi.com/a/bjad/tfxpf3p5.htm 请使用支持CSS3的浏览器查看.请把光标放到图片上,然后再移到图片外,注意效果. 原图 大图 以下是源代码 ...
- 利用CSS3实现图片无间断轮播图的实现思路
前言:图片轮播效果现在在各大网站都是非常普遍的,以前我们都是通过postion的left or right来控制dom的移动,这里我要说的是利用css3来制作轮播!相比以前通过postion来移动do ...
- 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(九)地图定位模块
config.xml文件的配置如下: <widget label="地图定位" config="widgets/esri/Location/LocationWidg ...
- Unity V3 初步使用 —— 为我的.NET项目从简单三层架构转到IOC做准备
[声明]由于本人表达能力有限,为避免不必要的误人子弟,本文将不会涉及IOC与DI,仅仅描述新版本Unity 3的使用(非Unity 3D,如果您想看的是Unity 3D请立即离开,否则莫怪此处“谋财害 ...
- SQL Server快捷键
SQL Server快捷键 金刚 SQL Server 快捷键 自己汇总的键盘操作快捷键 F7 切换到对象资源管理器 F5 执行T-Sql语句 F6 跳转到列属性 Alt+Enter 表属性 其实还有 ...
- python 函数式编程
1高阶函数 1.1 变量可以指向函数,可以把一个函数赋值给变量 如下代码 >>> f = abs >>> f(10) 10 1.2 变量可以指向函数,函数的形参也能 ...
- vim easy-align插件使用
https://github.com/junegunn/vim-easy-align 用vundle安装, 添加下面到vimrc Plugin 'junegunn/vim-easy-align' &q ...
- 72个可交付成果(PMBOK2008)
成果名称 包括内容 来自 用于 事业环境因素 组织文化.政府法规.行业标准.市场条件.工作授权系统.商业数据库.项目管理信息系统 外部现有的 启动.规划.执行过程的输入 组织过程资产 流程与程序(模板 ...