Search code examples
wcfweb-servicessoapdocx

Returning Docx File from Asp.net Webservice


I am trying to return docx file from an asp.net service but the service keeps on giving me a response error that it requires text/xml to be returned. The service is SOAP based asp.net webservice and i would like to know how can i return a docx file using a webservice? Or should i go for WCF for this one because i think soap has its limitations?


Solution

  • First of all WCF and SOAP are not interchangeable terms :) You were probably wondering about ASP.net webservice vs. WCF based one...

    In any case, for working with documents (files, images, etc, etc) where a client expects to receive a complete file, I would recommend using WCF and then use streaming. By using streaming you don't have to load entire file contents in memory, it is much more memory friendly solution and it handles large data size. There are some limitations when using streaming (have to use messages vs. data contracts and there is only few system defined bindings you can use - these are all documented in the link above).

    Hope this helps!