8

In my Application I use many Webservices. As the WSDL does not change, I have integrated the WSDL files in my project. If I use the WSDL2Java Tool from CXF, the WSDL locations absolute path is hardcoded.

Now my Question is, how to change the "wsdlocation" parameter in the @WebserviceClient Annotation to a relative path?

Here is a example:

@WebServiceClient(name = "Time", 
                  wsdlLocation = "file:/C:/Users/dominik/Documents/NetBeansProjects/Webservices/src/wsdl/Time.wsdl" ) /*I want this path to be relative */
public class Time extends Service {
Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
Dominik Obermaier
  • 5,610
  • 4
  • 34
  • 45

3 Answers3

13

I finally figured out how to do this correctly today. Just put the files is your resources folder and then you can use wsdlLocation to refer to them relatively like this:

<wsdlLocation>classpath:wsdl/myservice.wsdl</wsdlLocation>

See my answer to a similar question here: https://stackoverflow.com/a/9875701/1190144

Community
  • 1
  • 1
Kyle
  • 3,549
  • 1
  • 19
  • 25
  • Combine with because if you use it only the not works! – bl4ckr0se Apr 24 '20 at 11:35
  • Sadly this fails for me on version 3.4.4 of the plugin due to "Invalid WSDL URL: classpath". If I remove the classpath: it prefixes the full path which isn't correct for the deployment – David Bradley Sep 10 '21 at 14:58
2

Here is what one can do for generating an empty wsdl location

<wsdlOptions>
  <wsdlOption>
    <wsdl>${basedir}/src/main/wsdl/service.wsdl</wsdl>
    <extraargs>
      <extraarg>-wsdlLocation</extraarg>
      <wsdlurl />
    </extraargs>
  </wsdlOption>
</wsdlOptions>

The client then can receive the wsdl location as an argument and become an portable client. That's why I was looking for use an relative path: achieve an portable client

Camilo Silva
  • 8,283
  • 4
  • 41
  • 61
0

The wsdl2java tool has a -wsdlLocation flag that can be used to specify the exact string that is placed in there.

Daniel Kulp
  • 14,447
  • 4
  • 45
  • 37