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 / March 2007

Tip: Looking for answers? Try searching our database.

Transferring large binary files to web service-How to

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John K - 09 Mar 2007 15:20 GMT
Hello

I have an existing web service in C# 2005 that utilizes Web Service
Enhancments 3.0 with custom UsernameTokenManager authentication.  I need to
pass very large binary files to the web service for subsequent storage into a
database.  When we do this as part of a web service function, we get errors
like "The underlying connection was closed: An unexpected error occurred",
which I believe are due to the fact we are sending a very large byte array as
a parameter to the web service function which I think causes a timeout.  Our
web service utilizes SSL (https).

What is the best way to transmit large binary files to a web service
function?  Should the web service initiate an HTTP based file transfer
instead of trying to send it as a parameter in the function call?  Please
provide or point to example code.
Signature

Thank you.

Mariano Omar Rodriguez - 09 Mar 2007 16:51 GMT
The best option to transport binary data is use MTOM.
I attach the address of a sample
http://www.codeproject.com/soap/MTOMWebServices.asp

> Hello
>
[quoted text clipped - 16 lines]
> instead of trying to send it as a parameter in the function call?  Please
> provide or point to example code.
Steven Cheng[MSFT] - 12 Mar 2007 03:30 GMT
Hello John,

I agree with Mariano. For ASP.NET webservice with WSE 3.0, the preferred
approach of transfering large binary data is using MTOM encoding. This is a
W3C standard for new webservice soap specification and it interopable for
multiple webservice platforms.  The advantage of MTOM is that it will
transfer those binary data as raw binary stream rather than the text
encoded values as normal webservice binary transfering. Here are some web
articles introducing this:

#Optimize Large Data Transfer in Web Services with MTOM
http://blogs.digineer.com/blogs/tabraham/archive/2006/12/07/optimize-large-d
ata-transfer-in-web-services-with-mtom.aspx

#Sending files in chunks with MTOM Web Services and .NET 2.0
http://tim.mackey.ie/CommentView,guid,9603c0e9-a99e-4d6e-bfef-d4abb7ae9501.a
spx

Also, as you get the "The underlying connection was closed: An unexpected
error occurred" exception, it is likely that the ASP.NET server-side worker
thread(processing) has been timeout or the memory uploaded has exceed the
runtime limitation. For such case that you'll need to transfer large data
to ASP.NET server-side, you have to enlarge the executionTimeout and
maxRequestLength setting for your ASP.NET web application. This setting can
be configured through the <httpRuntime> elementi n web.config file:

#httpRuntime Element (ASP.NET Settings Schema)  
http://msdn2.microsoft.com/en-us/library/e1f13641.aspx

Look at the "maxRequestLength" and "executionTimeout" attributes(for max
timeout and max upload data size), this is what you need to enlarge
according to your application scenario.

If you have any further questions on this, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.

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.