I have a web service client which works perfectly fine, within which there is a line that defines the location of the WSDL:
@WebServiceClient(name = "CReceiveMOMessageService",
targetNamespace = "http://...",
wsdlLocation = "CReceiveMOMessageService.wsdl")
The code piece should be exported as a runnable JAR and is intended to work on a remote location.
When I define the location of the WSDL as above, it looks for a WSDL file at the directory in which I run the JAR file. Instead what I would like to do is to add the WSDL file to the project folder and export as JAR after that, and configure wsdlLocation parameter in a way that it points to the WSDL within the JAR file.
How can this be achieved?
It is possible to add the WSDL to the JAR. It seems that the convention is to place the WSDL in the JAR at the
META-INF/wsdllocation (although Oracle tools seem to favorMETA-INF/wsdls(see point 9 of this Oracle tutorial for example).I haven’t used the Oracle Enterprise Pack for Eclipse and I guess the OEPE ClientGen task does the correct generation of the client classes when you specify to package the WSDL inside the JAR but I don’t think it’s the same as passing a
-wsdllocation META-INF/wsdls/YourService.wsdlparameter when runningwsimport.exe:wsimport.exewill output@WebServiceClient(... wsdlLocation = "META-INF/wsdls/YourService.wsdl")but will also normally generate code like this in the static initializer of the class:which will still point to a root folder to which it then adds the provided WSDL path to finally get a non existent path.
You will have to change the class after it’s generated to include something like this instead:
which will now point within the JAR. Off course you must pack the WSDL at that location when building the client JAR.