G
Guest
I am working on a VB .net application which accesses a Java Servlet.
This servlet returns a binary stream that is written onto a PDF and then
this file is printed. Even though this file is downloaded and printed on most
environments, it fails to do so on one of the environments with the following
error:
"Unable to read data from the transport connection."
Also to be noted is the fact that when this servlet is hit from a different
geography, the response is obtained in perfect order and the file also gets
generated. Here's the sample code that does it:
Dim req As HttpWebRequest
Dim res As HttpWebResponse
req = WebRequest.Create("https://**********")
req.Method = "GET"
req.CookieContainer = New CookieContainer
req.CookieContainer.Add(ccContainer.GetCookies(req.RequestUri))
req.ContentType = "text/xml"
' Send the text to the webserver
res = req.GetResponse()
Dim Cook As Cookie
For Each Cook In res.Cookies
Me.ccContainer.Add(Cook)
'MsgBox(Cook.Name)
Next
' Wrap the response stream with a text-based reader
Dim sr As BinaryReader = New BinaryReader(res.GetResponseStream())
' Read the returned text into a textbox
Dim bWriter As New BinaryWriter(File.OpenWrite("temp.pdf"))
bWriter.Write(sr.ReadBytes(99999999))
bWriter.Close()
It seems to me that the problem creeps up when you're trying to access the
response stream to associate with the binary reader. However, I have not been
able to validate this.
Any pointers to this are gladly appreciated.
Regards,
Sanjeev
This servlet returns a binary stream that is written onto a PDF and then
this file is printed. Even though this file is downloaded and printed on most
environments, it fails to do so on one of the environments with the following
error:
"Unable to read data from the transport connection."
Also to be noted is the fact that when this servlet is hit from a different
geography, the response is obtained in perfect order and the file also gets
generated. Here's the sample code that does it:
Dim req As HttpWebRequest
Dim res As HttpWebResponse
req = WebRequest.Create("https://**********")
req.Method = "GET"
req.CookieContainer = New CookieContainer
req.CookieContainer.Add(ccContainer.GetCookies(req.RequestUri))
req.ContentType = "text/xml"
' Send the text to the webserver
res = req.GetResponse()
Dim Cook As Cookie
For Each Cook In res.Cookies
Me.ccContainer.Add(Cook)
'MsgBox(Cook.Name)
Next
' Wrap the response stream with a text-based reader
Dim sr As BinaryReader = New BinaryReader(res.GetResponseStream())
' Read the returned text into a textbox
Dim bWriter As New BinaryWriter(File.OpenWrite("temp.pdf"))
bWriter.Write(sr.ReadBytes(99999999))
bWriter.Close()
It seems to me that the problem creeps up when you're trying to access the
response stream to associate with the binary reader. However, I have not been
able to validate this.
Any pointers to this are gladly appreciated.
Regards,
Sanjeev