I generated SOAP client stub with CXF 3.4.2 codegen Maven plugin. However, when trying to create the service stub created, I get a bunch of errors like that:
There's no ObjectFactory with an @XmlElementDecl for the element {http://tempuri.org/}travelDocumentNumber.
this problem is related to the following location:
at protected javax.xml.bind.JAXBElement org.tempuri.GetActiveVisasForArrival.travelDocumentNumber
at org.tempuri.GetActiveVisasForArrival
However, there is an object factory containing the following code:
@XmlElementDecl(namespace = "http://tempuri.org/", name = "travelDocumentNumber", scope = GetActiveVisasForArrival.class)
public JAXBElement<String> createGetActiveVisasForArrivalTravelDocumentNumber(String value) {
return new JAXBElement<String>(_GetActiveVisasForArrivalTravelDocumentNumber_QNAME, String.class, GetActiveVisasForArrival.class, value);
}
As I can see, such error comes with every parameter of WS interface method (excluding XMLGregorianCalendar) and every returning value.
How can I get rid of those errors?
I generate the code this way:
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>./generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>./src/main/resources/wsdl/evisa.wsdl</wsdl>
<serviceName>BorderManagementSystemService</serviceName>
<extraargs>
<extraarg>-client</extraarg>
<extraarg>-verbose</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
How I initialize the service:
service = (IBorderManagementSystemService) new BorderManagementSystemService(new URL(WSDL_LOCATION)).getBasicHttpBindingIBorderManagementSystemService();
The WSDL file was exposed by some C# web service. I used single WSDL option; however, generating from root WSDL causes same errors.