调用webservice的问题 - javax.xml.ws.WebServiceException和类没有名称的属性 [英] Problems calling webservice - javax.xml.ws.WebServiceException and class do not have a property of the name

查看:1054
本文介绍了调用webservice的问题 - javax.xml.ws.WebServiceException和类没有名称的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个wsdl文件,很多xsd文件,jxb绑定文件。我使用Apache CXF cxf-codegen-plugin创建了一个Web服务客户端。创建Java类时没有任何错误。但是当我尝试调用任何生成的方法时,我得到一个异常:

I have a wsdl file, lot of xsd files, jxb binding file. I created a web service client using Apache CXF cxf-codegen-plugin. Java classes are created without any errors. But when I try to call any of the generated methods, I get an exception:

Exception in thread "main" javax.xml.ws.WebServiceException: class com.amadeus.xml.pnracc_11_1_1a.PNRReply do not have a property of the name {http://xml.amadeus.com/PNRACC_11_1_1A}PNR_Reply

我这样调用webservice方法(不要担心空值):

I call the webservice method like this (don't worry about the nulls):

AmadeusWebServices aws = new AmadeusWebServices();
aws.getAmadeusWebServicesPort().fareMasterPricerCalendar(null, null);

堆栈追踪:

Exception in thread "main" javax.xml.ws.WebServiceException: class com.amadeus.xml.pnracc_11_1_1a.PNRReply do not have a property of the name {http://xml.amadeus.com/PNRACC_11_1_1A}PNR_Reply
at com.sun.xml.internal.ws.client.sei.ValueSetter$AsyncBeanValueSetter.<init>(ValueSetter.java:165)
at com.sun.xml.internal.ws.client.sei.ValueSetterFactory$AsyncBeanValueSetterFactory.get(ValueSetterFactory.java:67)
at com.sun.xml.internal.ws.client.sei.SEIMethodHandler.buildResponseBuilder(SEIMethodHandler.java:163)
at com.sun.xml.internal.ws.client.sei.AsyncMethodHandler.<init>(AsyncMethodHandler.java:121)
at com.sun.xml.internal.ws.client.sei.PollingMethodHandler.<init>(PollingMethodHandler.java:39)
at com.sun.xml.internal.ws.client.sei.SEIStub.initMethodHandlers(SEIStub.java:99)
at com.sun.xml.internal.ws.client.sei.SEIStub.<init>(SEIStub.java:73)
at com.sun.xml.internal.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:590)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:330)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:312)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:294)
at javax.xml.ws.Service.getPort(Service.java:119)
at com.amadeus.xml.AmadeusWebServices.getAmadeusWebServicesPort(AmadeusWebServices.java:78)
at com.mycompany.test1.App.main(App.java:16)
Caused by: javax.xml.bind.JAXBException: {http://xml.amadeus.com/PNRACC_11_1_1A}PNR_Reply is not a valid property on class com.amadeus.xml.pnracc_11_1_1a.PNRReply
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getElementPropertyAccessor(JAXBContextImpl.java:966)
at com.sun.xml.internal.ws.client.sei.ValueSetter$AsyncBeanValueSetter.<init>(ValueSetter.java:162)
... 13 more

我的环境:

java version "1.7.0_21"
OpenJDK Runtime Environment (IcedTea 2.3.9) (7u21-2.3.9-5)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
NetBeans IDE 7.3.1

我错过了什么吗?我正在尝试创建非常简单的Web服务客户端。
我把示例项目与我在 GitHub 上使用的所有wsdl和xsd文件放在一起

Am I missing something? I am jus trying to create very simple web service client. I've put sample project with all the wsdl and xsd files I'm using on GitHub

感谢您提出任何建议。

推荐答案

看起来你打了Oracle JAX-WS实现中的一个错误。如果你添加:

Looks like you hit a bug in Oracle's JAX-WS implementation. If you add:

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-frontend-jaxws</artifactId>
    <version>${cxf.version}</version>
</dependency>

使用CXF的JAX-WS实现的依赖项,似乎工作正常。我也尝试使用wsimport命令生成代码并获得相同的错误,因此生成的代码似乎没问题。

to the dependencies to use CXF's JAX-WS implementation, it seems to work OK. I also tried generating the code with the wsimport command and get the same error so the generated code seems OK.

这篇关于调用webservice的问题 - javax.xml.ws.WebServiceException和类没有名称的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆