protected void Page_Load(object sender, EventArgs e) { if (Application["RMKGuide"] == null) { Application["RMKGuide"] = new List <string>(); } List <string> RMKGuide = (List <string>)(Application["RMKGuide"]); Response.ContentType = "text/xml"; StreamReader reader = new StreamReader(Request.InputStream); String xmlData = reader.ReadToEnd(); RMKRequestData rqd = new RMKRequestData(); RMKResponseData rsd = new RMKResponseData(); try { rqd.parseRequest(xmlData); if (rqd.operationId.Length < 1) { rsd.operationId = Guid.NewGuid().ToString(); rsd.message = "Операция успешно сохранена"; } else { rsd.operationId = ""; } } catch (Exception e1) { rsd.status = false; rsd.operationId = ""; rsd.message = e1.Message; } Application["RMKGuide"] = RMKGuide; Response.Write(rsd.createResponse()); Response.End(); }
private RMKResponseData RunRequestService(string body) { RMKResponseData res = null; //string str = "<?xml version =\"1.0\" encoding =\"utf-16\"?><RmkResponse xmlns:xsi =\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd = \"http://www.w3.org/2001/XMLSchema\"><status>true</status><OperationID>1d51cf78-e64f-468a-a2ea-f507f43cbbc3</OperationID></RmkResponse>"; //res = new RMKResponseData(); //WebLog.LogClass.WriteToLog("Ответ сервиса: {0}", str); //if (String.IsNullOrEmpty(str)) //{ // res.status = false; // res.operationId = ""; // res.message = "Не получены данные от службы"; //} //else //{ // res.parseResponse(str); //} //return res; BasicHttpBinding binding = new BasicHttpBinding(); binding.Name = "BasicHttpBinding_CaPService"; binding.CloseTimeout = TimeSpan.FromMinutes(1); binding.OpenTimeout = TimeSpan.FromMinutes(1); binding.ReceiveTimeout = TimeSpan.FromMinutes(10); binding.SendTimeout = TimeSpan.FromMinutes(1); binding.AllowCookies = false; binding.BypassProxyOnLocal = false; binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; binding.MaxBufferSize = 65536; binding.MaxBufferPoolSize = 524288; binding.MessageEncoding = WSMessageEncoding.Text; binding.TextEncoding = System.Text.Encoding.UTF8; binding.TransferMode = TransferMode.Buffered; binding.UseDefaultWebProxy = true; binding.ReaderQuotas.MaxDepth = 32; binding.ReaderQuotas.MaxStringContentLength = 8192; binding.ReaderQuotas.MaxArrayLength = 16384; binding.ReaderQuotas.MaxBytesPerRead = 4096; binding.ReaderQuotas.MaxNameTableCharCount = 16384; LogData = "RMK request:\n"; if (String.IsNullOrEmpty(_url)) { if (!isService) { WebLog.LogClass.WriteToLog(body); } else { LogData += body; } RMKResponseData r = new RMKResponseData(); r.status = true; r.message = "debug result: ok"; r.operationId = Guid.NewGuid().ToString(); LogData += "\nRMK emulation response:\n"; LogData += r.createResponse(); return(r); } Uri baseAddress = new Uri(_url); if (!isService) { WebLog.LogClass.WriteToLog(body); } else { LogData += body; } using (ChannelFactory <RmkTwoCaPService.IBasicHttpBinding_CaPService> ServiceProxy = new ChannelFactory <RmkTwoCaPService.IBasicHttpBinding_CaPService>(binding, new EndpointAddress(baseAddress))) { ServiceProxy.Open(); RmkTwoCaPService.IBasicHttpBinding_CaPService client = ServiceProxy.CreateChannel(); string stream = client.CreateCaPOperation(body); res = new RMKResponseData(); LogData += "\nRMK response:\n"; if (!isService) { WebLog.LogClass.WriteToLog("Ответ сервиса: {0}", stream); } else { LogData += stream; } if (String.IsNullOrEmpty(stream)) { res.status = false; res.operationId = ""; res.message = "Не получены данные от службы"; } else { res.parseResponse(stream); } return(res); } }