WCF公告:修改发送公告的时间

时间:2016-08-17 17:40:23

标签: wcf discovery

Microsoft表示您可以自定义通知functionality

有没有人有修改何时发送在线公告的经验?有人能指导我一个例子吗?

我尝试过使用AnnounceOnline方法但是我的代码一定有问题,因为我收到一条错误,指出“目标机器拒绝了它”

1 个答案:

答案 0 :(得分:0)

如果这可以帮助任何人,请在这里找到答案:

Private Sub AnnounceService()
    Dim baseAddress As New Uri(String.Format("net.tcp://{0}:10000", Net.Dns.GetHostEntry(Net.Dns.GetHostName).AddressList(1).ToString()))
    Dim serviceHost As New ServiceHost(GetType(WCFService), baseAddress)
    Dim endPoint As ServiceEndpoint = serviceHost.AddServiceEndpoint(GetType(IWCFService), New NetTcpBinding(SecurityMode.None), "WCFService")
    Dim epAddress As New EndpointAddress(baseAddress)

    Dim client As New AnnouncementClient(New UdpAnnouncementEndpoint())
    Dim epDiscoveryMetaData = EndpointDiscoveryMetadata.FromServiceEndpoint(endPoint)

    client.AnnounceOnline(epDiscoveryMetaData)

End Sub