I'm using the -clientjar wsimport parameter to export my WebService into a jar.
>wsimport -d C:\webservice -keep -clientjar webservice.jar http://localhost:8080/WebService?wsdl
A folder with the source code (.java files) and a webservice.jar are created.
The jar looks like this:
com
|
company
|
webservice
|
a bunch of .class files
META-INF
|
wsdl
|
wsdl file
However, when I put it on the WEB-INF/lib folder in my project, the classes are in the (default package) and are named like
com\company\webservice\file.class
I can't understand why. I've also used the -p parameter to specify a package name but it doesn't work.
Any clues?
Best Answer
There are two options of achieving this , both works like a charm. And both options can be automated from ant\gradle you name it .
1.To use -clientjar and then to repack the sources
2.Manually insert the wsdl into jar and customize the wsdLlocation URL
Assuming you have C:\WSDL\SO\stas.wsdl (I was running on windows)
First option
This creates StasWebServiceClient.jar jar file , but when importing it to eclipse, the sources are not importable , because of the topic problem (default package).
=> Unzip the jar file to current folder , you can use 7zip, or any other great zip tool , or you can run
to unzip the jar .
Folder hierarchy should look like
=> Do
this will create another jar , StasWebServiceClientCorrect.jar , which now has the correct packaging .
Second option
=> Run wsimport
to generate the code .I always like to have -keep option there , but it's up to you.
=> create META-INF folder
=> Create META-INF/wsdl folder
=> go one folder up .
=> Copy stas.wsdl file into META-INF\wsdl\stas.wsdl
=> Create a jar archive
Import the jar to workspace. When you will be creating the actual call to the service , use :