0

I'm a bit stuck with an issue. I'm developing a Java/Swing desktop application to run some Soap test. To run the Soap test I perform a curl call.

So, when I run this code:

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

The application freezes.

This is the part of the code which invoques the function above:

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();
}
Wolfchamane
  • 255
  • 1
  • 5
  • 23
  • Many applications get upset if you don't read there output streams. Take a look at [this](http://stackoverflow.com/questions/15218892/running-a-java-program-from-another-java-program/15220419#15220419) for an example. Also, don't forget that `waitFor` is a blocking method... – MadProgrammer May 30 '13 at 10:12
  • Nevermind, I've decided to use javax.xml.soap library, it seems better and by the moment, works. – Wolfchamane May 30 '13 at 10:42

0 Answers0