Java/Swing-curl发僵了

Java/Swing-curl发僵了,java,curl,Java,Curl,我有点被一个问题缠住了。 我正在开发一个Java/Swing桌面应用程序来运行一些Soap测试。 为了运行Soap测试,我执行了一个curl调用 因此,当我运行此代码时: public int excuteCommand(String cmd, Process pcs) throws IOException, InterruptedException{ Runtime run = Runtime.getRuntime(); pcs = run.exec(cmd); return

我有点被一个问题缠住了。 我正在开发一个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();
}

如果不读取输出流,许多应用程序会感到不安。请看一个例子。另外,不要忘记,
waitFor
是一种阻塞方法……不过,我已经决定使用javax.xml.soap库,它看起来更好,而且目前还可以工作。