可以使用以下代码将wsdl文件从URL中读取,并将其传递给wsdl2code命令:
//从URL中读取wsdl文件
String wsdlUrl = "http://example.com/service?wsdl";
InputStream wsdlInputStream = new URL(wsdlUrl).openStream();
//将wsdl文件传递给wsdl2code命令
File outputDir = new File("output");
String[] args = new String[]{"-uri", wsdlUrl, "-o", outputDir.getAbsolutePath()};
ToolRunner.run(new Configuration(), new WSDL2Java(), args);
其中,“output”路径为生成的代码的输出路径。