2010-10-20 68 views
1

我想發送一個xml文件並獲取一個xml文件作爲響應。我想發送的文件略高於20,000 KB。我嘗試添加一個超時值,並將keepalive設置爲false,但都沒有工作。我四處搜尋,但找不到適合我的任何內容。截至目前,我只是將文件分解併發送至3至4千字之間的文件。如果有人有任何想法,我會很感激。感謝名單。HttpWebRequest:請求被中止:請求被取消

HttpWebRequest hrequest = (HttpWebRequest)WebRequest.Create(); 
hrequest.KeepAlive = false; 
hrequest.Timeout = 10000 * 60; 
hrequest.Method = "POST"; 
hrequest.Headers.Add("Authorization", "Basic " + 
    Convert.ToBase64String(Encoding.ASCII.GetBytes(""))); 
hrequest.ContentType = "application/x-www-form-urlencoded"; 
Byte[] byteArray = Encoding.UTF8.GetBytes(
    File.ReadAllText("C:\\Payvment\\UploadProductsXML\\" + qStart + ".xml")); 
hrequest.ContentLength = byteArray.Length; 
Stream reqStream = hrequest.GetRequestStream(); 
reqStream.Write(byteArray, 0, byteArray.Length); 
reqStream.Close(); 
StreamReader streamRdr = new StreamReader(
    hrequest.GetResponse().GetResponseStream()); 
string strResponse = streamRdr.ReadToEnd(); 
StringReader stringRdr = new StringReader(strResponse); 
+0

您並未指出您遇到的* actual *問題。你是否遇到異常,或者發生了其他事情?另外,爲什麼你不使用Web服務?或者這種選擇不適用於你? – casperOne 2010-10-20 16:33:28

+0

你有沒有考慮過使用FTP? – jimplode 2010-10-20 16:32:49

+0

我無法使用ftp,我正在使用來自其他公司的web服務 – sse 2010-10-22 13:03:19

回答

1

Web服務器絕對不會允許請求很大,除非您更改消息大小max。在wcf屬性是maxRecievedMessageSize,默認爲64k。另外,這些屬性中的一些,最大大小/超時是服務器上的屬性,修改您的請求不會改變主意。

相關問題