Reputation: 4562
I've got a WCF Web Service running that accepts the following (REST):
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/StatusUpdate")]
string SMSUpdateStatus(Stream input);
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/ReceiveSMS")]
string SMSReceived(Stream input);
In order to authenticate the request, I need to combine each value passed in the POST (ContentType: application/x-www-form-urlencoded), hash them with a particular key, and then compare it to a specific header value.
I had this working fine without the validation by using something like this:
StreamReader sr = new StreamReader(input);
string s = sr.ReadToEnd();
sr.Dispose();
NameValueCollection qs = HttpUtility.ParseQueryString(s));
string Val1= qs["val_a"];
string Val2= qs["val_b"];
I can't seem to figure out how to pull out a header value (which I need to do for my comparison) or split my NameValueCollection, which appears to simply hold my entire payload in a single key.
Upvotes: 0
Views: 635
Reputation: 1840
Perhaps trying:
OperationContext.Current.IncomingMessageHeaders
would be of service? I haven't tested this, but I am interested to hear your results
Upvotes: 1