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

问题描述 投票:0回答:1

微软表示您可以自定义公告功能

有人有修改在线公告发送时间的经验吗?有人可以指导我举个例子吗?

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

wcf wcf-discovery
1个回答
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
© www.soinside.com 2019 - 2024. All rights reserved.