Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / November 2005

Tip: Looking for answers? Try searching our database.

Upload / Download via WebService

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Julia Beresford - 30 Nov 2005 16:33 GMT
Hi

My application consists of a database, WebService and web application.  The
web application reads and writes data to the database via the WebService.  I
also want to be able to upload/download files via the WebService because my
WebService handles security.

My question is - how can this best be done?  After some googleing a solution
I found was to stream bytes in a method like this:

<WebMethod()> _
   Public Function UploadFile(ByVal docbinaryarray As Byte(), ByVal docname
As String) As Boolean
       Dim strdocPath As String
       strdocPath = "C:\Inetpub\wwwroot\FileUploadDownloadSvc\temp\" +
docname
       Dim objfilestream = New System.IO.FileStream(strdocPath,
System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite)
       objfilestream.Write(docbinaryarray, 0, docbinaryarray.Length)
       objfilestream.Close()
       Return True
   End Function


Will this handle large files?  Is this the best way to do it or is there
another better solution?

Many thanks!

Julia Beresford
Peter Kelcey - 30 Nov 2005 17:55 GMT
Julia

There are a number of options you can use for transmitting large
amounts of binary data.  The solution you've listed (known as
base-64-encoding) is an okay solution. Your data will be transmitted
properly and it will be contained within your SOAP envelope  (meaning
that you can use things like WS-Security) if you want. It is a highly
interoperable and composable solution. The downside is that it isn't a
very efficient solution. Base 64 encoding of your binary data results
in it bloating up anywhere from 33-100% during the transmission. If you
are planning on transmitting large amounts of data quickly, then you
might potentially run into some performance and latency issues.

There are some other options out there such as DIME and SOAP with
Attachments (SwA). But both of these have issues of their own. The
solution I currently recommend people looking closely at is using
Message Transmission Optimization Mechanism (MTOM). MTOM comes with the
Web Services Enhancements 3.0 from Microsoft. It's a really easy to use
technology that avoids a lot of the pitfalls of the other options.

I've written a brief overview of the different solutions and
specifically MTOM. You can check it out at
http://peterkelcey.com/pk_blog/index.php?m=20051119

I'd also suggest checking out the following article on MSDN
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwebsrv/html/o
paquedata.asp


Hope that helps

Peter Kelcey

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.