Open houyouliang opened 7 years ago
@Test public void getWebServiceResponse() { String xml = WebServiceUtils.visitWebService(url, params); String xmlTypeName = findClassName(xml); String fileTemp = String.valueOf(System.currentTimeMillis()); String webserviceclass = "E:/webserviceclass/"; String javaSourcePath = webserviceclass + fileTemp + "/"; File javaSourceFile = new File(javaSourcePath); if (!javaSourceFile.exists()) { javaSourceFile.mkdirs(); } String packageName = "com.flight.mu"; String jarPath = "E:/webservicejar/" + packageName.replaceAll("\.", "/") + "/" + fileTemp + ".jar"; String wsimportCommand = "wsimport -d "+javaSourcePath+" -p "+packageName+" " + url; String jarCommand = "jar cvf "+jarPath+" -C "+ javaSourcePath + " ."; File jarFile = new File(jarPath); // 检测是否存在目录 if (!jarFile.getParentFile().exists()) { jarFile.getParentFile().mkdirs(); } if (jarFile.exists()) { jarFile.delete(); } try { System.out.println("run javac reslt code:" + Runtime.getRuntime().exec(CommandUtils.getOSCommand(wsimportCommand)).waitFor()); System.out.println("run javac reslt code:" + Runtime.getRuntime().exec(CommandUtils.getOSCommand(jarCommand)).waitFor()); } catch (InterruptedException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } System.out.println(getClassName(xmlTypeName, jarPath)); }
public class WebServiceUtils {