如何从WCF经营合同中检索客户端的机器名? [英] How to retrieve the client's machine name from within a WCF Operation Contract?

查看:144
本文介绍了如何从WCF经营合同中检索客户端的机器名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前看OperationContect.Current属性。是否有一个(嵌套)属性将始终返回客户端的计算机名称?我目前使用net.tcp绑定,但想在未来支持更多的绑定。



使用.NET 3.5 SP1


< DIV CLASS =h2_lin>解决方案

您可以从当前的OperationContext的IncomingMessageProperties,如远程端点的IP地址:

  RemoteEndpointMessageProperty messageProperty = OperationContext.Current.IncomingMessageProperties [RemoteEndpointMessageProperty.Name]作为RemoteEndpointMessageProperty; 
Console.WriteLine(远程地址为:{0},messageProperty.Address);


I'm currently looking at the OperationContect.Current properties. Is there a (nested) property the will always return the machine name of the client? I'm currently using net.tcp binding, but would like to support additional bindings in the future.

Using .NET 3.5 SP1

解决方案

You can get the remote endpoint's IP address from the current OperationContext's IncomingMessageProperties, eg:

RemoteEndpointMessageProperty messageProperty = OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
Console.WriteLine("Remote address is: {0}", messageProperty.Address);

这篇关于如何从WCF经营合同中检索客户端的机器名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆