我正在尝试发送请求的原始数据并进行了一些研究,发现Page.Request.InputStream
我需要但当我进入我的页面时它总是空的。
我是这个概念的新手,因为我来自 C# 中的 Windows 窗体应用程序。
这是我加载的页面:
public override void process(NameValueCollection parametersReceived)
{
string urlDestination = "";
urlDestination = parametersReceived[Includes.SUPPLIER_URL];
Stream str; String strSoapMessage = "";
Int32 strLen, strRead;
str = Request.InputStream;
strLen = Convert.ToInt32(str.Length);
byte[] strArr = new byte[strLen];
strRead = str.Read(strArr, 0, strLen);
for (int i = 0; i < strLen; i++)
{
if (strSoapMessage.Length > 0)
strSoapMessage += "&";
strSoapMessage += strArr[i].ToString();
}
saveMyLog("DATA COMMUNICATION: \n Destination: " + urlDestination + "\n Request: " + strSoapMessage);
HttpWebRequest webRequest = null;
webRequest = (HttpWebRequest)WebRequest.Create(new Uri(urlDestination));
webRequest.Method = "POST";
webRequest.ContentType = "text/xml";
webRequest.Headers.Add("SOAPAction", urlDestination);
using (StreamWriter requestStream = new StreamWriter(webRequest.GetRequestStream()))
{
requestStream.Write(strSoapMessage);
}
strSoapMessage = "";
strSoapMessage = new StreamReader(webRequest.GetResponse().GetResponseStream()).ReadToEnd();
Response.Write(strSoapMessage);
saveMyLog("\n Status: " + ((HttpWebResponse)webRequest.GetResponse()).StatusCode.ToString() + "\n Response: " + strSoapMessage);
}
谢谢!