【问题标题】:WCF - Who is connecting to meWCF - 谁在连接我
【发布时间】:2008-12-31 19:29:50
【问题描述】:

使用 WCF,我如何确定谁在连接到我的服务器?

背景:我有一组 WCF 客户端和服务器。我怀疑一个客户端指向了错误的服务器,所以我想记录到该服务器的所有连接。不知道是哪个客户端,只好在服务器端查看。

【问题讨论】:

    标签: .net wcf


    【解决方案1】:

    这在 3.5 中通过RemoteEndpointMessageProperty 是最简单的;见here

    【讨论】:

    • 有没有比“Dim remoteAddress = CType(OperationContext.Current.IncomingMessageProperties("System.ServiceModel.Channels.RemoteEndpointMessageProperty"), System.ServiceModel.Channels.RemoteEndpointMessageProperty).Address”更简洁的语法跨度>
    • 好吧,您至少可以避免使用字符串文字(请参阅 Marc 发布的答案中的“此处”链接)。
    【解决方案2】:
    OperationContext opCtx = OperationContext.Current;
    EndpointAddress from = opCtx.IncomingMessageHeaders.From;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-08
      • 2010-11-26
      • 2011-10-27
      • 2011-02-10
      相关资源
      最近更新 更多