0

我有点被一个问题困住了。我正在开发一个 Java/Swing 桌面应用程序来运行一些 Soap 测试。要运行 Soap 测试,我执行 curl 调用。

所以,当我运行这段代码时:

public int excuteCommand(String cmd, Process pcs) throws IOException, InterruptedException{
   Runtime run = Runtime.getRuntime();
   pcs = run.exec(cmd);
   return pcs.waitFor();
}

应用程序冻结。

这是调用上述函数的代码部分:

Process ps = null;
try{
   //1. prepare inputFile.xml
   //2. create outputFile.xml (if not exists, Win compatibility)
   //3. create curl command
   Curl oCurl = new Curl();
   oCurl.setData(inputFile); //inputFile should contain SoapEnvelope and CDATA request
   oCurl.setProxy(settings.getProxy()); //maybe there's proxy setting
   oCurl.setHeader(settings.getHeader()); //set content-type and charset
   oCurl.setAction(settings.getAction()); //set SOAPAction
   oCurl.setTarget(settings.getTarget()); //set http://server:port/service target
   oCurl.setOutput(outputFile); //set output file
   String cmd = oCurl.getCommand();
   if (executeCommand(cmd, ps) == 0)
      consoleLog("Test complete!", INFO_LOG);
}catch(Exception e){
   consoleLog(e.getMessage(), ERROR_LOG);
}finally{
   if (ps != null)
      ps.destroy();
}
4

0 回答 0