I have a wcf service currently used. I need to add a restful method inside my wcf service. Like below as a sample:
[OperationContract]
string GetDataWcf();
[OperationContract]
[WebGet(UriTemplate = "Employee/{id}")]
Employee GetEmployeeById(string id);
I have an inspection class that inspects incoming and outgoing messages. I want to know that if a service call was made to rest service or wcf service. How can I understand this.
public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
{
Uri requestUri = request.Headers.To;
HttpRequestMessageProperty httpReq = (HttpRequestMessageProperty)request.Properties[HttpRequestMessageProperty.Name];
OkTrace.WriteLine(string.Format("{0} {1}", httpReq.Method, requestUri));
foreach (var header in httpReq.Headers.AllKeys)
{
OkTrace.WriteLine(string.Format("{0}: {1}", header, httpReq.Headers[header]));
}
if (!request.IsEmpty)
{
OkTrace.AddBlankLine();OkTrace.WriteLineOnly(MessageToString(ref request));
}
return requestUri;
}
public void BeforeSendReply(ref Message reply, object correlationState)
{
OkTrace.WriteLine(string.Format("Response to request to {0}:", (Uri)correlationState));
HttpResponseMessageProperty httpResp = (HttpResponseMessageProperty)reply.Properties[HttpResponseMessageProperty.Name];
OkTrace.WriteLine(string.Format("{0} {1}", (int)httpResp.StatusCode, httpResp.StatusCode));
if (!reply.IsEmpty)
{
OkTrace.AddBlankLine();
OkTrace.WriteLineOnly(MessageToString(ref reply));
}
}
Thanks in advance