I have two simple web services, as shown below. One returns the file size of
a test file, and the second the file itself. I can successfully recover the
file size using the following code:\
httpRequest.Method = "Post"
httpRequest.ContentType = "text/xml; charset=utf-8"
httpResponse = httpRequest.GetResponse()
Dimsr As NewStreamReader(httpResponse.GetResponseStream())
strStatus = sr.ReadToEnd()
sr.Close()
httpResponse.Close()
However, when I try to download the file itself, using the following code,
the app just hangs:
DimhttpRequest2 As HttpWebRequest =
WebRequest.Create("http://localhost:1995/webSvs/Service.asmx/RetrieveZip")
httpRequest2.Method = "Post"
httpRequest2.ContentLength = lFileLength
httpRequest2.ContentType = "application/x-zip-compressed"
httpResponse2 = httpRequest2.GetResponse()' hangs here.
Any suggestion how I can retrieve this zip file and write it to my local
disk? Thanks.
Joe
Here are the web services themselves:
Public ClassService
InheritsSystem.Web.Services.WebService
<WebMethod()_
PublicFunction RetrieveZip() As Byte()
Dimpath As String=
"U:\-CVS-\Painless.NET\RandD\webSvs\App_Code\test.zip"
Dimbindata() As Byte= File.ReadAllBytes(path)
Returnbindata
EndFunction
<WebMethod()_
PublicFunction RetrieveZipSize() As String
Dimpath As String=
"U:\-CVS-\Painless.NET\RandD\webSvs\App_Code\test.zip"
DimlFileSize As Long
DimstrFileSize As String
lFileSize = FileLen(path)
strFileSize = CStr(lFileSize)
ReturnstrFileSize
EndFunction
End Class