3
我試圖發送一個請求的原始數據,並做了一些研究,發現Page.Request.InputStream
想要我需要,但是當我進入我的頁面時,它總是空的。Request.InputStream始終爲空
我是新來的這個概念,因爲我來自Windows窗體應用程序在C#中。
這是我的網頁,我加載:
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);
}
謝謝!
我已經tryed這一點,如果我暫停breake只是befor我打開我的網頁看看Request.InputStream好說0 – XandrUu
好沒有工作,在這種情況下,您可能會想要顯示您的代碼:客戶端和服務器。 –
我更新了問題 – XandrUu