1

我有一项服务,它适用于这样的 URLhttp://localhost:1253/NotificationProducer

然后我尝试在服务器端添加一个端点,它将像这样监听 URL:http://localhost:1253/NotificationProducer/1

BasemanagerReference 是http://localhost:1253/NotificationProducer

ServiceHost svcHost = new ServiceHost(typeof(NotificationProducer), new Uri( BaseResources.baseManagerReference ));

svcHost.AddServiceEndpoint(typeof(INotificationProducer),
                           new WSHttpBinding(),
                           new Uri(BaseResources.baseManagerReference),
                           new Uri(BaseResources.baseManagerReference+"/"+id));

List<string> endpointslist = new List<string>();

foreach (var endpoint in svcHost.Description.Endpoints)
{
    .Add(endpoint.Address.Uri.AbsoluteUri);
}

但是在所有这些操作之后,我的端点列表仅包含http://localhost:1253/NotificationProducer 并且当我以编程方式将客户端中的端点地址更改为http://localhost:1253/NotificationProducer/1我捕获到一个错误时,它告诉我,该地址上没有侦听器。

那么如何正确添加端点或侦听器?抱歉,我是 WCF 的新手,没有使用这些功能,也没有在 msdn 上找到答案。

4

0 回答 0