wsimport -clientjar generates classes in (default package)

Bubumuk picture Bubumuk · Sep 23, 2013 · Viewed 15.7k times · Source

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?

Answer

peterh picture peterh · Jul 1, 2014

I think the problem here is that -clientjar option is meant for an entirely different purpose than the OP expects.

The purpose of the -clientjar option is to embed a copy of the WSDL inside the generated artifacts so that it can become part of the application's jar file. The benefit of having a bundled WSDL (and actually using it of course) is that the web service consumer does not have to make a call to the endpoint to download the WSDL every time it initiates itself.

Links:

https://weblogs.java.net/blog/ramapulavarthi/archive/2010/09/03/wsimport-clientjar-option-ease-client-side-web-service-progra

Using jaxws-maven-plugin with -clientjar option