I am using WsImport
to generate some Java sources from a remote WSDL file. Note that this is being from inside a regular Scala project i.e. it is not being done
Can you modify your val xjcArgs
to include classpath there. e.g
val xjcArgs = "-cp _path_ofjaxb2-basics.jar:other_plugin_jar_with_path -B-Xequals -B-XhashCode -B-Xvalue-constructor"
to make sure classpath is set on WSImport call?
Edit
Based on comment: here is my ant command that does. Basically you need all the supporting jars as well.
In my D:/tmp.wsimport I have following jars:
233,859 commons-beanutils-1.9.2.jar
315,805 commons-lang3-3.1.jar
293,543 commons-lang3-3.1.jar.zip
60,686 commons-logging-1.1.1.jar
23,205 istack-commons-runtime-2.21.jar
7,595 istack-commons-tools-1.1.jar
25,446 istack-commons-tools-2.21.jar
866,992 jaxb-impl-2.1.10.jar
3,147,690 jaxb-xjc-2.1.11.jar
141,087 jaxb2-basics-1.11.1.jar
166,736 jaxb2-basics-runtime-1.11.1.jar
141,604 jaxb2-basics-tools-1.11.1.jar
5,756 jaxb2-value-constructor-3.0.jar
1,284,131 jaxws-rt-2.1.4.jar
510,892 jaxws-tools-2.1.4.jar
33,739 stax-ex-1.7.7.jar
130,161 streambuffer-0.9.jar
Just call Ant's default target and you will get proper java files.
Edit 2 to support command line/programmatic call.
.
Option 1:
Call just the WSImport.
"jdk_location\bin\java.exe" -cp "lib\*" com.sun.tools.ws.WsImport -keep -verbose -B-Xequals -B-XhashCode -B-Xvalue-constructor http://www.webservicex.com/globalweather.asmx?WSDL
Option 2
Call via custom class.
Java class:
package test;
import com.sun.tools.ws.WsImport;
public class Test
{
public static void main(String args []) throws Throwable
{
WsImport.doMain(args);
}
}
Command prompt call
"jdk_location\bin\java.exe" -cp ".;lib\*" test.Test -keep -verbose -B-Xequals -B-XhashCode -B-Xvalue-constructo
r -Xnocompile http://www.webservicex.com/globalweather.asmx?WSDL
Option 2c
Again a custom java class/method which you can use in scala to use. Make sure you have the classpath properly set with the jars I listed.
package test;
import com.sun.tools.ws.WsImport;
public class MyWSImport {
public static void main(String[] args) throws Throwable {
String [] input = new String[] {"-keep",
"-verbose","-B-Xequals",
"-B-XhashCode",
"-B-Xvalue-constructor","-Xnocompile",
"http://www.webservicex.com/globalweather.asmx?WSDL"};
WsImport.doMain(input);
}
public void execute() throws Throwable
{
String [] input = new String[] {"-keep",
"-verbose","-B-Xequals",
"-B-XhashCode",
"-B-Xvalue-constructor","-Xnocompile",
"http://www.webservicex.com/globalweather.asmx?WSDL"};
WsImport.doMain(input);
}
}