Search code examples
javawsdlversionwsimportgenerated-code

When generating .java files in Java by using wsimiport on .wsdl file, is there a way to specify the source code version?


I'm generating .java files using wsimport in the command line as follows:

C:\temp>"%JAVA_HOME%\bin\wsimport" -d . -p com.package.name -keep -extension -Xnocompile File.wsdl

I'm successfully generating .java files from the .wsdl files I'm giving it, but the .java files' source version is at least 5.0 as it includes varargs [function(Integer... myInts)] and annotations (@WebServiceClient(...) etc.).

It's easy enough to comment out the annotations, but the varargs are proving a little more difficult to convert for compliance to my source version (1.3). Is there a simple way to tell wsimport to generate source code at a certain compliance level? Or is there a better solution?


Solution

  • This is not an answer to the original question since I was unable to determine a viable way to change the outputted source code version, however, I found a workaround.

    My original desire was to include the generated source files into my project and compile them myself. If instead I removed the -Xnocompile from the above command, making it:

    C:\temp>"%JAVA_HOME%\bin\wsimport" -d . -p com.package.name -keep -extension File.wsdl
    

    it instead outputs the necessary .class files to interact with this particular web service. It removes my ability to compile the code myself, but the class files are no longer code-version dependent, so they were perfectly compatible with my project, and simply needed to be included in the build path.