我有一个wsdl文件,很多xsd文件,jxb绑定文件.我使用Apache CXF cxf-codegen-plugin创建了一个Web服务客户端.创建Java类没有任何错误.但是当我尝试调用任何生成的方法时,我得到一个例外:
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方法(不要担心空值):
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文件放在一起
谢谢你的任何建议.
解决方法:
看起来你在Oracle的JAX-WS实现中遇到了一个错误.如果你添加:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
对于使用CXF的JAX-WS实现的依赖项,它似乎工作正常.我也尝试使用wsimport命令生成代码并获得相同的错误,因此生成的代码似乎没问题.