Download binary data from WebService

  • Thread starter Thread starter Nikolay Petrov
  • Start date Start date
N

Nikolay Petrov

Any general ideas how to get binary data(files) from WebService to an
ASP .NET app and then save it to client's machine?

Thanks
 
Nikolay,

You have first to serialize them.

A sample from Tom that I find nice

\\\Tom Shelton
Private Function SerializeFontObject(ByVal fnt As Font) As String
Dim bf As New BinaryFormatter
Dim mem As New MemoryStream
Try
bf.Serialize(mem, fnt)
Return Convert.ToBase64String(mem.ToArray())
Catch
Return String.Empty
Finally
mem.Close()
End Try
End Function
Private Function DeserializeFontObject(ByVal fnt As String) As Font
Dim bf As New BinaryFormatter
Dim mem As New MemoryStream(Convert.FromBase64String(fnt))
Try
Return DirectCast(bf.Deserialize(mem), Font)
Finally
If Not mem Is Nothing Then
mem.Close()
End If
End Try
End Function

I hope this helps a little bit?

Cor
 
I know I can also use DIME attachments, so I don't need to convert the
data to Base64.

my question was not very exact .

I am looking in to way of sending big files (over 10MB). The way of
using DIME attachements is good for this, because i can split the files
to parts, not send them as one piece. I've used the for upload and it
works great.

The problem is that I can't figure out how to ask the web service for
the first part, then second and so on.

when uploading to web service i do a FOR loop and send chunks if data
to service, which concantenates them in file, but how to make the
service reads parts of the file and send them is unclear to me.

the reason i want to split the transfered files to parts is that it
will consume a lot of memory at the server if I read the whole file,
serialize it and then start sending it.
 
Nikolay,

I thought I answered this question already like this, however when not.

Why don't you just download them with webclient downloadfile, where you get
the url from the webservice

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top