字符串strURL =(Request.IsSecureConnection?“ https://website.com/Transaction.asmx”:“ http://website.com/wTransaction.asmx”);
字符串strCommand = clsMisc.strGetDataFromPage(this,“ c”,“”,PostMethod.BOTH);
字符串strAppCode = clsMisc.strGetDataFromPage(this,“ a”,“ WEBIN”,PostMethod.BOTH);
字符串strVenueCode = clsMisc.strGetDataFromPage(this,“ v”,“”,PostMethod.BOTH);
long transcationid = long.Parse(clsMisc.strGetDataFromPage(this,“ t”,“ 0”,PostMethod.BOTH));
字符串strParam1 = clsMisc.strGetDataFromPage(this,“ p1”,“”,PostMethod.BOTH);
字符串strParam2 = clsMisc.strGetDataFromPage(this,“ p2”,“”,PostMethod.BOTH);
字符串strParam3 = clsMisc.strGetDataFromPage(this,“ p3”,“”,PostMethod.BOTH);
字符串strParam4 = clsMisc.strGetDataFromPage(this,“ p4”,“”,PostMethod.BOTH);
StringBuilder sbrPost = new StringBuilder();
string strIPAddress = Request.UserHostAddress.ToString();
if (Request.Headers.ToString().Contains("&X-Forwarded-For="))
{
strIPAddress = Request.Headers["X-Forwarded-For"].ToString();
}
strAppCode = "|APPCODE=" + strAppCode + "|IPADDRESS=" + strIPAddress + "|";
//strAppCode = "|APPCODE=" + strAppCode + "|IPADDRESS=" + Request.UserHostAddress.ToString() + "|";
sbrPost.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
sbrPost.Append("<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\"><soap12:Body><objExecute xmlns=\"http://www.website.com/\">");
sbrPost.Append("<strAppCode>" + strAppCode + "</strAppCode>");
sbrPost.Append("<lngTransactionIdentifier>" + lngTransId + "</lngTransactionIdentifier>");
sbrPost.Append("<strCommand>" + strCommand + "</strCommand>");
sbrPost.Append("<strParam1>" + strParam1 + "</strParam1>");
sbrPost.Append("<strParam2>" + strParam2 + "</strParam2>");
sbrPost.Append("<strParam3>" + strParam3 + "</strParam3>");
sbrPost.Append("<strParam4>" + strParam4 + "</strParam4>");
</objExecute></soap12:Body></soap12:Envelope>");
string strPost = sbrPost.ToString();
WebRequest objReq = WebRequest.Create(strURL);
WebResponse objRes;
StreamReader smrRes;
byte[] bytData = Encoding.UTF8.GetBytes(strPost);
objReq.Method = "POST";
objReq.ContentType = "application/soap+xml";
objReq.ContentLength = bytData.Length;
objReq.Timeout = 600000; // 10 minutes
Stream objPost = objReq.GetRequestStream();
objPost.Write(bytData, 0, bytData.Length);
objPost.Close();
objRes = objReq.GetResponse();
smrRes = new StreamReader(objRes.GetResponseStream());
Response.Write(smrRes.ReadToEnd());
Response.ContentType = "text/xml";
smrRes.Close();
Response.End();
}
catch (Exception err)
{
clsLog.blnLogError(strErrorPage,strErrorMethod, "",err.Message);
}
}
我在da行objPost.Close()上收到错误; .....不寻常的错误是,当我在Visual Studio 2010中使用F10逐行缓慢调试此代码时,该代码有效..但是当我只是运行该程序,甚至快速调试该程序...它在该行上引发错误..它给出了一个错误,该错误是预期打开的连接已被服务器关闭。
地狱PPP !!!
最佳答案
如果您在调试时认为它工作正常,请尝试使用Thread.Sleep(10000)。