I need to develop a restful web service, that can accept a stream, along with some parameters. From what I have seen and read, a web service that has a Stream input cannot accept any other parameters, yet here is an example showing a working example that accepts a string parameter as well.
I have a web service that looks like so:
[ServiceContract]
public interface ISender
{
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
int Upload(Stream fileStream);
}
public int Upload(Stream fileStream)
{
//this does not parse correctly and provide all of the querystring keys (I dont know why)
NameValueCollection postParameters = HttpUtility.ParseQueryString(new StreamReader(fileStream).ReadToEnd());
return 1;
}
But what I really want to do is to be able to accept other string parameters.
THis post, creating a webservice that accepts a file (Stream) doesnt want other params, suggests that when you send a stream it sends everything in the request.
So, for the sake of keeping the post short, I've not mentioned the client. Before attempting to post data to this service, I would like to know whether I am going about this in the right way? Have I setup my web service correctly, and if it is correct that a web service that contains a stream input parameter can only contain a single parameter, how do I obtain access both to the stream, and any other text data I have sent across?