Hello,
When I'm uploading an file to a JRun WebServer (third party) with a Windows
Forms application, l always get an TimeOut while uploading, all other request
who doesn't request an post are going ok? Why? I've tried almost everything.
I also tried the KB888528 solution but this also doesn't work.
What can the KB887563 do for me?
Machine( tried on Windows 2003 Server & WinXp)
Microsoft .NET Framework 1.1 SP1
I'll hope somebody could help me because this is very frustrating.
Thanx in advance.
Greetz,
Joey Chömpff
My Code:
private void Initialize()
{
// Create a new request to the mentioned URL.
_request = (HttpWebRequest ) WebRequest.Crea te(_url);
_request.Header s.Set("Pragma", "no-cache");
_request.UserAg ent = "Sample";
_request.Timeou t = 30000;
_request.Method = "GET";
_request.Conten tType="text/xml";
_request.AllowA utoRedirect = true;
_request.KeepAl ive = false;
_request.Cookie Container = _cookieJar;
_request.Creden tials = CredentialCache .DefaultCredent ials;
ServicePointMan ager.Certificat ePolicy = new EBatchSecurityP olicy();
if (UseProxy)
{
_proxy = (WebProxy) _request.Proxy;
_proxy.Credenti als = new NetworkCredenti al(_proxyUserNa me, _proxyPassword) ;
_request.Proxy= _proxy;
}
}
private void AddPostData()
{
string boundary = "---------------------------" +
DateTime.Now.Ti cks.ToString("x ");
_request.Conten tType = "multipart/form-data; boundary=" + boundary;
_request.Method = "POST";
// Build up the post message header
StringBuilder sb = new StringBuilder() ;
sb.Append("--");
sb.Append(bound ary);
sb.Append("\r\n ");
sb.Append("Cont ent-Disposition: form-data; name=\"");
sb.Append("file ");
sb.Append("\"; filename=\"");
sb.Append(_file NameToPost);
sb.Append("\"") ;
sb.Append("\r\n ");
sb.Append("Cont ent-Type: application/octet-stream");
sb.Append("\r\n ");
sb.Append("\r\n ");
string postHeader = sb.ToString();
byte[] postHeaderBytes = Encoding.Defaul t.GetBytes(post Header);
// Build the trailing boundary string as a byte array
// ensuring the boundary appears on a line by itself
byte[] boundaryBytes =
Encoding.Defaul t.GetBytes(stri ng.Format("\r\n--{0}--\r\n",boundary) );
using(MemoryStr eam stream = new MemoryStream())
{
// Write out our post header
stream.Write(po stHeaderBytes, 0, postHeaderBytes .Length);
// Write out the file contents
byte[] buffer = new Byte[checked((uint) Math.Min(4096, (int)
_dataToPost.Len gth))];
int bytesRead = 0;
int totalBytesRead = 0;
while ( (bytesRead = _dataToPost.Rea d(buffer, 0, buffer.Length)) != 0 )
{
stream.Write(bu ffer, 0, bytesRead);
totalBytesRead += bytesRead;
}
// Write out the trailing boundary
stream.Write(bo undaryBytes, 0, boundaryBytes.L ength);
long length = postHeaderBytes .Length + totalBytesRead +
boundaryBytes.L ength;
_request.Conten tLength = length;
using(Stream requestStream = _request.GetReq uestStream())
{
stream.WriteTo( requestStream);
requestStream.C lose();
}
stream.Close();
}
}
public ResponseBase GetResponse(Typ e responseType)
{
if (_dataToPost != null && _dataToPost.Len gth > 0)
AddPostData();
// Read the response
using(HttpWebRe sponse webResponse = (HttpWebRespons e)_request.GetR esponse())
{
ResponseBase response = null;
using (StreamReader sr = new
StreamReader(we bResponse.GetRe sponseStream(), System.Text.UTF 8Encoding.UTF8) )
{
string responseString = sr.ReadToEnd();
using(StringRea der stringReader = new StringReader(re sponseString))
{
response = (ResponseBase) Serializer.Read (responseType, stringReader);
stringReader.Cl ose();
}
sr.Close();
}
webResponse.Clo se();
return response;
}
}
My Exception:
Message: The operation has timed-out. StackTrace: at
System.Net.Http WebRequest.GetR esponse()
at ECH.EBatch.Comm on.Communicatio n.EBatchCommuni cator.GetRespon se(Type
responseType)
at ECH.EBatch.Comm on.EBatchManage r.GetResponse(E BatchService service,
String url, Type responseType, Stream dataToPost, String fileName)
at ECH.EBatch.Comm on.EBatchManage r.UploadFile(St ring fileName,
EBatchService ebatchService)
at
ECH.EBatch.Test Application.EBa tchManagerTest. UploadOldFiles( EBatchService
service)
at ECH.EBatch.Test Application.frm Main.btnUpload_ Click(Object sender,
EventArgs e)
When I'm uploading an file to a JRun WebServer (third party) with a Windows
Forms application, l always get an TimeOut while uploading, all other request
who doesn't request an post are going ok? Why? I've tried almost everything.
I also tried the KB888528 solution but this also doesn't work.
What can the KB887563 do for me?
Machine( tried on Windows 2003 Server & WinXp)
Microsoft .NET Framework 1.1 SP1
I'll hope somebody could help me because this is very frustrating.
Thanx in advance.
Greetz,
Joey Chömpff
My Code:
private void Initialize()
{
// Create a new request to the mentioned URL.
_request = (HttpWebRequest ) WebRequest.Crea te(_url);
_request.Header s.Set("Pragma", "no-cache");
_request.UserAg ent = "Sample";
_request.Timeou t = 30000;
_request.Method = "GET";
_request.Conten tType="text/xml";
_request.AllowA utoRedirect = true;
_request.KeepAl ive = false;
_request.Cookie Container = _cookieJar;
_request.Creden tials = CredentialCache .DefaultCredent ials;
ServicePointMan ager.Certificat ePolicy = new EBatchSecurityP olicy();
if (UseProxy)
{
_proxy = (WebProxy) _request.Proxy;
_proxy.Credenti als = new NetworkCredenti al(_proxyUserNa me, _proxyPassword) ;
_request.Proxy= _proxy;
}
}
private void AddPostData()
{
string boundary = "---------------------------" +
DateTime.Now.Ti cks.ToString("x ");
_request.Conten tType = "multipart/form-data; boundary=" + boundary;
_request.Method = "POST";
// Build up the post message header
StringBuilder sb = new StringBuilder() ;
sb.Append("--");
sb.Append(bound ary);
sb.Append("\r\n ");
sb.Append("Cont ent-Disposition: form-data; name=\"");
sb.Append("file ");
sb.Append("\"; filename=\"");
sb.Append(_file NameToPost);
sb.Append("\"") ;
sb.Append("\r\n ");
sb.Append("Cont ent-Type: application/octet-stream");
sb.Append("\r\n ");
sb.Append("\r\n ");
string postHeader = sb.ToString();
byte[] postHeaderBytes = Encoding.Defaul t.GetBytes(post Header);
// Build the trailing boundary string as a byte array
// ensuring the boundary appears on a line by itself
byte[] boundaryBytes =
Encoding.Defaul t.GetBytes(stri ng.Format("\r\n--{0}--\r\n",boundary) );
using(MemoryStr eam stream = new MemoryStream())
{
// Write out our post header
stream.Write(po stHeaderBytes, 0, postHeaderBytes .Length);
// Write out the file contents
byte[] buffer = new Byte[checked((uint) Math.Min(4096, (int)
_dataToPost.Len gth))];
int bytesRead = 0;
int totalBytesRead = 0;
while ( (bytesRead = _dataToPost.Rea d(buffer, 0, buffer.Length)) != 0 )
{
stream.Write(bu ffer, 0, bytesRead);
totalBytesRead += bytesRead;
}
// Write out the trailing boundary
stream.Write(bo undaryBytes, 0, boundaryBytes.L ength);
long length = postHeaderBytes .Length + totalBytesRead +
boundaryBytes.L ength;
_request.Conten tLength = length;
using(Stream requestStream = _request.GetReq uestStream())
{
stream.WriteTo( requestStream);
requestStream.C lose();
}
stream.Close();
}
}
public ResponseBase GetResponse(Typ e responseType)
{
if (_dataToPost != null && _dataToPost.Len gth > 0)
AddPostData();
// Read the response
using(HttpWebRe sponse webResponse = (HttpWebRespons e)_request.GetR esponse())
{
ResponseBase response = null;
using (StreamReader sr = new
StreamReader(we bResponse.GetRe sponseStream(), System.Text.UTF 8Encoding.UTF8) )
{
string responseString = sr.ReadToEnd();
using(StringRea der stringReader = new StringReader(re sponseString))
{
response = (ResponseBase) Serializer.Read (responseType, stringReader);
stringReader.Cl ose();
}
sr.Close();
}
webResponse.Clo se();
return response;
}
}
My Exception:
Message: The operation has timed-out. StackTrace: at
System.Net.Http WebRequest.GetR esponse()
at ECH.EBatch.Comm on.Communicatio n.EBatchCommuni cator.GetRespon se(Type
responseType)
at ECH.EBatch.Comm on.EBatchManage r.GetResponse(E BatchService service,
String url, Type responseType, Stream dataToPost, String fileName)
at ECH.EBatch.Comm on.EBatchManage r.UploadFile(St ring fileName,
EBatchService ebatchService)
at
ECH.EBatch.Test Application.EBa tchManagerTest. UploadOldFiles( EBatchService
service)
at ECH.EBatch.Test Application.frm Main.btnUpload_ Click(Object sender,
EventArgs e)
Comment