Я попытался с несколькими типами примеров вызвать файл .exe из другого .exe-файла с параметрами в
запустил «веб-сервис», но я получаю некоторые times '500 - Исключение внутренней ошибки сервера ".вызов .exe из другого .exe для запуска webservice
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("<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/\"><soap:Body>");
soapRequest.Append("<getCategory xmlns=\"http://tempuri.org/\">");
soapRequest.Append("<inBranch>" + strParam + "</inBranch>");
soapRequest.Append("<dir>" + strParamDir + "</dir>");
soapRequest.Append("<modifyDateFrom>" + strModifyDateFrom + "</modifyDateFrom>");
soapRequest.Append("<modifyDateTo>" + strModifyDateTo + "</modifyDateTo>");
soapRequest.Append("</getCategory>");
soapRequest.Append("</soap:Body></soap:Envelope>");
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();
// NOTE-- я должен запустить эту услугу в 8 раз с различными параметрами, когда я называю этот второй .EXE из 8 пакетных файлов один за другим, то не вопрос.
сейчас я пытаюсь запустить эту службу из моего первого .Exe instad из Batch-файла один за другим в событиях нажатия кнопки, после чего я получаю ошибку 500 при первом завершении второго события.
что я делаю неправильно, пожалуйста, дайте мне несколько предложений.
Попробуйте добавить "Process.WaitForExit();" после вашего Process.Start (startInfo); –