Jaxws-maven plugin allowing WSDL placement relative to class location, why?

I am using jaxws-maven-plugin version 2.1 . I found very strange code created to host WSDL from jar resources:

  <configuration> <keep>true</keep> <sourceDestDir>${basedir}/src/main/java</sourceDestDir> <extension>true</extension> <wsdlDirectory>${basedir}/src/main/resources/wsdl</wsdlDirectory> <packageName>my.package.gen</packageName> <wsdlLocation>wsdl/*</wsdlLocation> <wsdlFiles> <wsdlFile>mywsdl.wsdl</wsdlFile> </wsdlFiles> </configuration> 

And the generated code:

 static { URL url = null; try { URL baseUrl; baseUrl = my.package.gen.My_Service.class.getResource("."); url = new URL(baseUrl, "wsdl/mywsdl.wsdl"); } catch (MalformedURLException e) { logger.warning("Failed to create URL for the wsdl Location: 'wsdl/mywsdl.wsdl', retrying as a local file"); logger.warning(e.getMessage()); } MYSERVICE_WSDL_LOCATION = url; } 

Thus, the wsdl file is viewed in the directory (package) of the generated classes, and not in the main jar directory, as it would be logical. And WSDL could not be found.

Is this a bug in jaxws jaxws-maven-plugin , or is it a bug in my configuration?

+6
source share
2 answers

You should use jaxws-maven-plugin version 2.3 instead of 2.1, and the result will be what you expected.

Version 2.3 output looks like this (if your wsdl folder is under src / main / resources):

 URL url = <Any>.class.getClassLoader().getResource("wsdl/anywsdl.wsdl"); 
+2
source

To generate

 url = new URL(baseUrl, "wsdl/mywsdl.wsdl"); 

This is the alleged behavior, in accordance with this,

http://jax-ws-commons.java.net/jaxws-maven-plugin/wsimport-mojo.html#wsdlLocation

It depends on what you want to do.

If you have a problem,

My_Service.class.getResource ("");

You can get rid of the point (relative path) with something like:

 <plugin> <groupId>com.google.code.maven-replacer-plugin</groupId> <artifactId>replacer</artifactId> <version>1.5.0</version> <executions> <execution> <phase>process-sources</phase> <goals> <goal>replace</goal> </goals> </execution> </executions> <configuration> <file>target/generated-sources/wsimport/lu/hitec/webservices/pssu/${wsdl.app}/${interface.name}_Service.java</file> <replacements> <replacement> <token>_Service\.class\.getResource\("\."\)</token> <value>_Service\.class\.getResource\(""\)</value> </replacement> </replacements> </configuration> </plugin> 
+1
source

All Articles