1

To give some background, i have a WCF SOAP service in .NET that needs to return pdf files. This service will be used by multiple application, many times in a day. The size of the files returned varies from 10KB to 10MB. Also, there is no shared location where the file can be kept and the path can be returned. It can be done using byte[], but that will increase the load on service, which I want to avoid. Any suggestions are welcome.

Application is hosted as a windows service. It is being used mostly by Java Clients. When I am trying to directly return the file stream, at client side the return type does not get mapped to a proper class and returns a null object in an automatically generated empty class. Only in the case when I returned byte[], it was able to read the file.

9
  • How is your application hosted? I.e. web app, windows service, etc?
    – Pete
    Nov 24, 2014 at 8:25
  • You can directly return a Stream object in WCF. Would this help?
    – Marcel
    Nov 24, 2014 at 9:03
  • Application is hosted as a windows service. It is being used mostly by Java Clients. When I am trying to directly return the file stream, at client side the return type does not get mapped to a proper class and returns a null object and an automatically generated empty class.
    – Rj1705
    Nov 24, 2014 at 11:28
  • - Is there any exception (under the hood) like SerializationException?
    – Kaan
    Nov 24, 2014 at 13:30
  • - What is your return type? - FileStream is not serializable. - Streams should be transferred into a data structure. See Remarks on this MSDN page.
    – Kaan
    Nov 24, 2014 at 13:30

1 Answer 1

-2

Message Transmission Optimization Mechanism (MTOM) is a mechanism for transmitting large binary attachments with SOAP messages as raw bytes, allowing for smaller messages.

please refer : http://msdn.microsoft.com/en-us/library/aa395209.aspx for more details.

3
  • Does this answer the question that was asked? If it does, you might want to explain how. Nov 25, 2014 at 16:48
  • you need to apply messageEncoding as "Mtom". <wsHttpBinding> <binding name="WSHttpBinding_IUpload" messageEncoding="Mtom"/> </wsHttpBinding> Nov 25, 2014 at 17:15
  • MTOM is a very good solution. Was considering it earlier, but in my case the file sizes are variable and MTOM seems to be further increasing the size for smaller files. Maybe by adding some threshold value, I can use it.
    – Rj1705
    Nov 27, 2014 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.