如何获取服务实例的端点uri?

时间:2010-04-26 06:53:25

标签: c# .net wcf

我正在开发一个wcf服务,我需要它来找出它自己的端点地址(在构造函数中的pref。)。 这是否可能,如果是这样,有人能指出我正确的方向吗?该服务托管在IIS上。

2 个答案:

答案 0 :(得分:1)

要获取服务的端点列表,您需要执行以下操作:

// _ Service的类型为System.ServiceModel.ServiceHost

ServiceEndpointCollection endPoints_ = _Service.Description.Endpoints;

答案 1 :(得分:0)

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