WCF Service (REST) Download Issue

Hi,

I have developed a REST based WCF Service (Web role). The service exposes two methods: 1) Upload a file 2) Download file.

- Upload file method accepts the file content as stream and saves in the Azure blob storage, and this functionality is working fine.

- Download file: This method reads the blob from Azure storage and returns the stream. In this I am able to successfully load the content into memorystream and return it, but on the client side the content of the response is 0.

The OperationContract for download method:

 [WebGet(UriTemplate = "/{filename}")]
 [OperationContract]
 Stream DownloadFile(string filename);

Implementation of DownloadFile:

 public Stream DownloadFile(string filename)
 {
    MemoryStream stream = new MemoryStream();
 // Load the content into the stream from the blob           WebOperationContext.Current.OutgoingResponse.ContentType = "application/octet-stream";
    return stream;
}


Service.svc file content: (uses WebServiceHostFactory for service host)

<%@ ServiceHost Language="C#" Debug="true" Service="TestService.Test" CodeBehind="TestService.svc.cs" Factory="System.ServiceModel.Activation.WebServiceHostFactory"%>

Do I have to do some additional configurations for downloading? If no additional configurations required then what could be possible reasons (coding mistake or deployment issues) for download functionality not working?

Regards,

Tanish Sr.


March 26th, 2015 11:27am

Hi,

Thank you for posting in here.
We are checking on this and will get back at earliest.

Regards,
Manu Rekhar
Free Windows Admin Tool Kit Click here and download it now
March 27th, 2015 11:23am

Have you tried debugging locally and made sure that the code is able to download the stream correctly from the azure storage? what happens when you host the service locally? what is the exact error message you are getting?

you might want to refer the links below and check out the extra configurations which are set for response contents

http://www.codeproject.com/Articles/797979/Uploading-Downloading-a-file-using-WCF-REST-servic

http://blog.chinmoymohanty.com/uploadingdownloading-a-file-using-wcf-rest-service-in-net-3-5/

March 28th, 2015 8:52am

Hi,

Thanks for the response.

I am not getting error message or any exception. I have gone through the links and trying the configurations mentioned in the link. Will keep you updated on further development.

Regards,

Tanish Sr.

Free Windows Admin Tool Kit Click here and download it now
March 30th, 2015 1:46am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics