Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF: Distinguish between REST and SOAP requests using the OperationContext

In WCF security, given the current OperationContext, what is the best way to determine whether the request is a SOAP request or a REST request?

like image 798
urig Avatar asked Jul 05 '10 13:07

urig


1 Answers

You could look at the binding name on the ChannelDispatcher:

string bindingName = OperationContext.Current
                        .EndpointDispatcher.ChannelDispatcher.BindingName;

For REST, it would be webHttpBinding - anything else would be SOAP.

like image 149
marc_s Avatar answered Oct 06 '22 17:10

marc_s