Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relative Path for WSDL in CXF Webservice Client

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 {
like image 931
Dominik Obermaier Avatar asked Dec 02 '10 11:12

Dominik Obermaier


2 Answers

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

like image 119
Kyle Avatar answered Nov 16 '22 14:11

Kyle


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

like image 31
Camilo Silva Avatar answered Nov 16 '22 14:11

Camilo Silva