如何获取WCF的协议映射列表?

时间:2012-07-17 17:05:09

标签: c# .net vb.net wcf

我想知道是否有人知道如何获取WCF的协议映射列表(类似于 ServiceHost.AddDefaultEndpoints 函数为自己做的事情),无论是什么映射的来源(machine.config,app.config,web.config等)?

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。我在这里为其他人分享:

Dim pms As ProtocolMappingSection = CType(ConfigurationManager.GetSection("system.serviceModel/protocolMapping"), ProtocolMappingSection)
Dim pmc As ProtocolMappingElementCollection = pms.ProtocolMappingCollection

For Each pme As ProtocolMappingElement In pmc
    If String.Compare(pme.Scheme, uri.Scheme, True) = 0 Then
        ' Do something
        Exit For
    End If
Next