我有一个 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 文件放在一起
感谢您的任何建议。