How do I examine the settings for the endpoint that the message for the current operation was delivered to?
There are two sources of settings depending on whether you’re interested in the endpoint runtime settings or the endpoint description. The endpoint description is the blueprint from which the endpoint was built. The endpoint runtime is the machinery that processes messages.
Some of the information from the blueprint is thrown away by the runtime, such as the original binding used to construct the channel. Some of the information from the runtime didn’t come from the blueprint, such as the current state of the network objects that were built. Therefore, having just one of the sources isn’t sufficient to answer every query.
You can access the endpoint runtime directly from the operation context by examining OperationContext.Current.EndpointDispatcher.
To find the original endpoint description, you can search for it using the information in the endpoint runtime, assuming you haven’t done anything fancy with your service configuration:
OperationContext context = OperationContext.Current; Uri address = context.EndpointDispatcher.EndpointAddress.Uri; ServiceEndpoint endpoint = context.Host.Description.Endpoints.First(e => e.Address.Uri == address);