Webservice and upload of large files
Hi
I need some ideas on how to create a webservice (asmx) that can accept upload of large files. > 4mb up to > 100 mb
Currently I have created a 3 webmethod for uploading the file in smaller chucks using session. The first open a file via an filestream, the secound writes the different chuncks and the last closes the file. If something goes wrong then i need something that can clean up after failed uploads or else I have open handle to filestreams... I have tried using the session timedout and a shared timer, but then the timer cannot get access to the session variables.
Any ideas on how to solved this problem??
Any other ways to handle this problem? I have looked at WCF, but I cannot see if it is supported on other platforms than Windows
Answers
- I recommend that you not use WSE for this purpose. There are better ways to transfer files than by using obsolete software that's not even supported by Visual Studio 2008!
Your best bet would be to create a simple ASHX file (HttpHandler). It would still be a SOAP endpoint, but that shouldn't be a problem since the message format will be fairly simple. Use an XmlReader to read the input stream (again, the difficulty of using XmlReader will be mitigated by the fact that the message format will be simple).
The mesage format would start with any fixed parameters (file name, etc), followed by the file contents, as a base64-encoded value. You will be able to read this in chunks using the XmlReader.ReadValueChunk method.
John Saunders
WCF is Web Services. They are not two separate things.
Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
Use File->New Project to create Web Service Projects
- Marked As Answer byAmadeo Casas - MSFTModeratorWednesday, October 28, 2009 3:51 PM
All Replies
- Hi r_Madsen,
WCF OPTIONS :
The way out of this probelm in WCF is by using MTOM [Message Transfer Optimization Mechanism] Message encoding which handles transfer of large Binary data to and from webservice .
For more info check out http://weblogs.asp.net/ricardoperes/archive/2009/05/14/using-mtom-with-wcf.aspx
.NET 2.0 WEBSERVICES OPTIONS :
If you are planning to use ASP.NET 2.0 Webservices then I suggest you to use it in conjunction with WSE 3.0 with MTOM [Message Transfer Optimization Mechanism] .
For more info check out http://dotnetslackers.com/articles/aspnet/GettingStartedCreatingWSEEnabledWebService.aspx
Pls let me know if it worked by marking this post as answer .
Thanks
Anand R- Proposed As Answer byAnand.Ranganathan Tuesday, October 13, 2009 5:49 PM
If you're asking whether a WCF service can be used by clients on platforms other than Windows, then the answer is "yes, absolutely". If this was your question, then your answer is "WCF". ASMX web services are now considered by Microsoft to be "legacy technology" - all new web service development should be done in WCF if at all possible.I have looked at WCF, but I cannot see if it is supported on other platforms than Windows
John Saunders
WCF is Web Services. They are not two separate things.
Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
Use File->New Project to create Web Service Projects
- Marked As Answer byDaniel RothModeratorThursday, October 22, 2009 5:30 PM
- Unmarked As Answer byDaniel RothModeratorThursday, October 22, 2009 5:30 PM
Ok, do know of any framework that can read a autogenerated WCF stub?? Mono??
For instance if I create service and use a filereader as input, then it should be handle somehow. If the stub is supported then it should be no problem, but if it is not supported do you have any idea of how to it?- Sorry can you be a little elaborate on your requirement, but looking at the first line in your post I can say I don't there is such a framework available .
Anand
Hey Anand
I need to create webservice where it is posible to upload potential large files (> 100 mb) and has the abbilty to used by other system than windows.
Rune- Hi r_Madsen,
WCF OPTIONS :
The way out of this probelm in WCF is by using MTOM [Message Transfer Optimization Mechanism] Message encoding which handles transfer of large Binary data to and from webservice .
For more info check out http://weblogs.asp.net/ricardoperes/archive/2009/05/14/using-mtom-with-wcf.aspx
.NET 2.0 WEBSERVICES OPTIONS :
If you are planning to use ASP.NET 2.0 Webservices then I suggest you to use it in conjunction with WSE 3.0 with MTOM [Message Transfer Optimization Mechanism] .
For more info check out http://dotnetslackers.com/articles/aspnet/GettingStartedCreatingWSEEnabledWebService.aspx- Proposed As Answer byAnand.Ranganathan Tuesday, October 13, 2009 5:49 PM
DID YOU CHECK OUT THE ".NET 2.0 WEBSERVICES OPTIONS" . In my earlier post in this same thread that's the way to handle large file transfers using Webservices.
I request you mark posts that answers your question as 'answers'
Thanks
Anand R
- Proposed As Answer byAnand.Ranganathan Thursday, October 22, 2009 1:11 PM
- Unproposed As Answer byJohn SaundersMVP, ModeratorThursday, October 22, 2009 1:24 PM
- Proposed As Answer byAnand.Ranganathan Tuesday, October 13, 2009 5:49 PM
- I recommend that you not use WSE for this purpose. There are better ways to transfer files than by using obsolete software that's not even supported by Visual Studio 2008!
Your best bet would be to create a simple ASHX file (HttpHandler). It would still be a SOAP endpoint, but that shouldn't be a problem since the message format will be fairly simple. Use an XmlReader to read the input stream (again, the difficulty of using XmlReader will be mitigated by the fact that the message format will be simple).
The mesage format would start with any fixed parameters (file name, etc), followed by the file contents, as a base64-encoded value. You will be able to read this in chunks using the XmlReader.ReadValueChunk method.
John Saunders
WCF is Web Services. They are not two separate things.
Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
Use File->New Project to create Web Service Projects
- Marked As Answer byAmadeo Casas - MSFTModeratorWednesday, October 28, 2009 3:51 PM
Ok, I will look at it...
Thanks for the input...


