How to detect binding from wcf service end

前端 未结 1 1125

suppose i have one wcf service with multiple endpoint having different type of binding like tcp, basichttp, wshttp etc.



        
1条回答
  •  被撕碎了的回忆
    2021-01-16 07:26

    Why exactly do you care about this? Your service really shouldn't care, overall, which binding the client used to get to the service if that is going to affect the service behavior (in that case, it might really make more sense to have multiple separate services).

    That said, I think one possible way would be to look at the endpoint address for the service, which I think you can get using something like this (untested):

    var opCtxt = OperationContext.Current;
    var epAddress = opCtxt.EndpointDispatcher.EndpointAddress;
    var uri = epAddress.Uri;
    

    0 讨论(0)
提交回复
热议问题