1

I have a WCF service and without changing any code on the client side, is there a way that I can know the detail information of the caller, such as the MachineName, and ApplicationName?

Basically, I cannot change the client code to pass those pieces of information over.

I tried to use System.Web.HttpContext on the server side to track this information, but HttpContext.Current is NULL. I guess that is not the proper usage of it.

Any suggestion?

Thanks Sarah

4

2 回答 2

2

我通过这篇文章找到了答案:Orcas 中的客户端 IP 地址

这是代码片段(使用 .NET 3.5):

// Track the IP address and port of the calling client
OperationContext context = OperationContext.Current;
MessageProperties properties = context.IncomingMessageProperties;
RemoteEndpointMessageProperty endpoint = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
Trace.TraceInformation("Receive a document from {0}:{1} via {2}", endpoint.Address, endpoint.Port, properties.Via.AbsoluteUri);
于 2010-03-16T23:54:07.917 回答
0

您可以在 WCF 3.5 中获取 IP 地址,但仅此而已(撇开双工服务,在此期间您可能会获得返回 URL)

于 2010-03-16T23:17:33.387 回答