Transferring large binary files to web service-How to

J

John K

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.
 
S

Steven Cheng[MSFT]

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.
 

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

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top