title: calling .exe from another .exe to run a webservice
body: <p>i have tried with several type of examples to call a .exe file from another .exe file with parameters to<br>
  run a 'web service',but i am getting some times '500 – Internal Server Error  exception'.</p>
  
  <pre><code>1. code in First .Exe(code for only for one event, i have 8 event like this to run in Button click)    
  
      dateTimePicker4.CustomFormat = "yyyy-MM-dd";   
              string frodate = dateTimePicker4.Value.Date.ToShortDateString();
              ProcessStartInfo startInfo = new ProcessStartInfo();
              startInfo.FileName = @"C:\WebserviceClient.exe";           // this is the second .EXE file
              startInfo.Arguments = "300000 supplier" + " " + frodate;   // thesse are the 3 parameters
              Process.Start(startInfo);
  
   2. My second .Exe file receive these parameters and call the Web-Service like below
  
  WebRequest webRequest = WebRequest.Create("http://My Server Path/epos/getproduct.asmx"); // this is web service in another location 
              HttpWebRequest httpRequest = (HttpWebRequest)webRequest;
              httpRequest.Method = "POST";
              httpRequest.ContentType = "text/xml; charset=utf-8";
              httpRequest.Headers.Add("SOAPAction: http://tempuri.org/getCategory");
              httpRequest.ProtocolVersion = HttpVersion.Version11;
              httpRequest.Credentials = CredentialCache.DefaultCredentials;
              Stream requestStream = httpRequest.GetRequestStream();
              //Create Stream and Complete Request             
              StreamWriter streamWriter = new StreamWriter(requestStream, Encoding.ASCII);
  
          StringBuilder soapRequest = new StringBuilder("&lt;soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
          soapRequest.Append(" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" ");
          soapRequest.Append("xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"&gt;&lt;soap:Body&gt;");
          soapRequest.Append("&lt;getCategory xmlns=\"http://tempuri.org/\"&gt;");
          soapRequest.Append("&lt;inBranch&gt;" + strParam + "&lt;/inBranch&gt;");
          soapRequest.Append("&lt;dir&gt;" + strParamDir + "&lt;/dir&gt;");
          soapRequest.Append("&lt;modifyDateFrom&gt;" + strModifyDateFrom + "&lt;/modifyDateFrom&gt;");
          soapRequest.Append("&lt;modifyDateTo&gt;" + strModifyDateTo + "&lt;/modifyDateTo&gt;");
          soapRequest.Append("&lt;/getCategory&gt;");
  
          soapRequest.Append("&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;");
  
          streamWriter.Write(soapRequest.ToString());
          streamWriter.Close();
          //Get the Response    
          HttpWebResponse wr = (HttpWebResponse)httpRequest.GetResponse();  // here i am getting the ERROR
          StreamReader srd = new StreamReader(wr.GetResponseStream());
          string resulXmlFromWebService = srd.ReadToEnd();
  </code></pre>
  
  <p>// NOTE-- i have to run this service 8 times with different parameters, when i call this second .EXE from 8 batch files one by one, then no issue.</p>
  
  <p>now i am trying to Run this service from my First .Exe instad of Batch file one by one in button click events , then i am getting the 500 error when first event complete second event start.</p>
  
  <p>what i am doing wrong,Please give me some suggestions.</p>