"Can not initialize the default wsdl from..." -- Why?
cxf, pom.xml, wsdl, wsdl2java
Solution
I notice the cfx examples use slightly different locations for `sourceRoot`, `wsdl` and `wsdlLocation`.
Remember that typically, files in `src/main/resources` are included in the produced artifact. In order for files in `src/main/wsdl` to be included, it needs to be added as a resource in the pom.xml:
<resources>
<resource>
<directory>src/main/wsdl</directory>
</resource>
</resources>
Tips:
- Set the paths you suspect to known bad paths and see if you get the same error-message.
- Unzip the produced `*.jar`-file(s) and check if the wsdl is included, and what the path is.
Problem
My `pom.xml` contains the following to auto generate a client for a working web service having the WSDL specified below: ``` <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId> <version>2.3.1</version> <executions> <execution> <id>generate-sources</id> <configuration> <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot> <wsdlOptions> <wsdlOption> <wsdl>${basedir}/src/main/wsdl/myclient.wsdl</wsdl> <extraargs> <extraarg>-client</extraarg> <extraarg>-verbose</extraarg> </extraargs> <wsdlLocation>wsdl/myclient.wsdl</wsdlLocation> </wsdlOption> </wsdlOptions> </configuration> <goals> <goal>wsdl2java</goal> </goals> </execution> </executions> </plugin> ``` The project builds fine, without any errors or warnings and I can see the the file `myclient.wsdl` in the JAR file right under a `wsdl` folder. But when I try running that JAR: ``` java -Xmx1028m -jar myclient-jar-with-dependencies.jar ``` It complains that "Can not initialize the default wsdl from wsdl/myclient.wsdl" Why? What am I missing? How can I find out what path that `wsdl/myclient.wsdl` in pom.xml translates into, that makes the client's JAR complain at run time? Update: I am aware of some solutions/workarounds that involve modifying the auto-generated code: - Pass "null" for the wsdl URL and then use the ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://example.com/....") to set the address. - load the WSDL as a Java resource and pass its location into your service's constructor. But I am more interested in a solution that requires entering the right values into the `pom.xml` like the classpath approach (but unfortunately classpath didn't work for me for some reason). Any ideas what I should be typing there instead? Apparently this is a very simply case of figuring out the correct path rules for that particular plugin, but I am missing something and I don't know what it is.
Related problems
- How to avoid the need to specify the WSDL location in a CXF or JAX-WS generated webservice client?
- How to decompile a whole Jar file?
- When generated an Apache CXF client, why is the WSDL still needed when instantiating the client?
- javax.xml.ws.WebServiceException: Port {http://tempuri.org/}WSHttpBinding_IDWService not found