开发者

Retrieve configuration bindings WCF

开发者 https://www.devze.com 2023-01-07 21:06 出处:网络
I have a service that exposes multiple endpoints. One beeing wsHttp and the other Net.Tcp. Is there any way I can know which one the clients used to make the call inside the service method ?

I have a service that exposes multiple endpoints. One beeing wsHttp and the other Net.Tcp. Is there any way I can know which one the clients used to make the call inside the service method ?

Thank开发者_开发技巧s !


You can use the OperationContext object to retrieve the channel information


if (OperationContext.Channel.LocalAddress.Uri.Scheme == Uri.UriSchemeHttp)
{
   // Called by wsHTTP
}
else if (OperationContext.Channel.LocalAddress.Uri.Scheme == Uri.UriSchemeNetTcp)
{
   // Called by NetTcp
}
...


Yes. If you look at the following property you should be able to tell where things came in from.

OperationContext.Current.EndpointDispatcher.EndpointAddress 
0

精彩评论

暂无评论...
验证码 换一张
取 消