I've been ripping my hair out for a while now. Can someone provide a really simple example (or a link to a working example) of how to upload a file to a WCF service hosted in IIS.
I've started with something simple. I want to call a URL from a client via POST, pass the name of the file and send the file as well. So I added the following to the contract:
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/UploadFile?fileName={fileName}")]
void Upload(string fileName, Stream stream);
The implemented it in the .svc file:
public void Upload(string fileName, Stream stream)
{
Debug.WriteLine((fileName));
}
Immediately, I get an error upon running the project:
For request in operation Upload to be a stream the operation must have a single parameter whose type is Stream.
Not sure where to go from here. Would love to see an actual working example.
P.S. I did this in .NET 4 with WCF 4 and it seemed a lot simpler, but I've had to downgrade. In .NET 3.5, I am missing something.