tags:

views:

26

answers:

2

Hi, 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

A: 

You can get the IP address in WCF 3.5, but that's it (setting aside duplex services during which you may get a return URL)

blowdart
+1  A: 

I found the answer through this article: Client IP addresses in Orcas.

And here is a snippet of the code (with .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);
erxuan