Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems calling webservice - javax.xml.ws.WebServiceException and class do not have a property of the name

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

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

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

Stack trace:

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

My environment:

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

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

Thank you for any suggestions.

like image 808
Michal J. Avatar asked Dec 20 '22 23:12

Michal J.


2 Answers

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>

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.

like image 174
Daniel Kulp Avatar answered Apr 29 '23 12:04

Daniel Kulp


I have faced this issue and find that it occurs because of encoding issues in generated java class, it is interesting that it throws same exception. Encoding Error Screenshot You can generate java class with wsimport -keep and check java classes for this issue.

like image 44
msari Avatar answered Apr 29 '23 12:04

msari