科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道基础软件WCF中如何得到客户端信息

WCF中如何得到客户端信息

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

本文是关于WCF中如何得到客户端信息的解释。

作者:汉飞扬 来源:CSDN 2008年2月17日

关键字: 客户端信息 WCF Linux

  • 评论
  • 分享微博
  • 分享邮件

引用两个post中的重点吧:(

David Wortendyke - MSFT:

 

Hello Jdang,

The NetTcpBinding wraps a TCP socket as a channel and sockets don't have any built-in feature for for providing the sender's machine-name. In other words, it isn't povided by the underlying transport so we don't have a way to surface it to you.

Do you have the option of modifying your contract so it includes the client's machine-name as one of the parameters? Alternately, you could add a message-inspector that adds the machine-name as a custom header that you then extract in your service.

Regards,
David

Clemens Vasters - MSFT :

What if you are using HTTP and the message is passing several proxies? What if you are using MSMQ? How about IPv6 addresses? What should be there when the message arrives via named pipes?

In other words: WCF abstracts away from the network details and provides a single programming model that's independent of what transport you choose. Some of those might be an abstraction over IP themselves or the concept of IP doesn't apply since they are a disk-based store & forward mechanism such as MSMQ. The additional issue of proxies and NATs adds an additional layer of complexity here. So while we might be able to give you some information bit in some cases, the quality of that information would vary from transport to transport.

For HTTP bindings, we do have some of the information you might want in the HttpRequestMessageProperty that you can retrieve from the message Properties collection either directly or with OperationContext.Current.IncomingMessageProperties[HttpRequestMessageProperty.Name]

Hope that helps
Clemens

 

   by stswordman



查看本文来源
    • 评论
    • 分享微博
    • 分享邮件
    邮件订阅

    如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。

    重磅专题
    往期文章
    最新文章