As part of a pretty large application I need to provide a REST Service that uploads an image. Since the whole application is .NET, I've been trying to find an working example of a WCF RESTFul Service that does that but couldn't (Which defines the whole configurations). There are handful of examples online but I couldn't (thanks to my lack of knowledge in WCF) make none of them work. (I keep getting exceptions thrown).
I'll be happy to get linked to a working one.
Please find a sample below:
On Server:
Interface:
My Implementation class:
NOTE: Make sure that your WCF Service application app pools identity has write access to the c:\Temp location to write the file. Alternatively you can replace the logic to save the image to db or any other way you want it to.
My web.config on server:
Now on my client i have the following code:
I am using a 3rd party tool RestSharp to post my request to the REST Service.
My request in fiddler looks as shown:
And when i perform a POST of the above request i get the below response:
Here is what I have done:
Create C# Windows console application
Create a new project of WCF Service remove
namespace AlumniService
from this code and replace your own namespace also interfaceIBIITAlumni
tooChanges in web.config
Enjoy!