OK, this is first short blog entry on some new features (and fixes) for WCF in .NET 3.5 and/or 3.0 SP1.
I know that a number of people have been complaining bitterly about not being able to get the information of the calling remote host in WCF v1, i.e. the address or DNS name and maybe even the port number the client process is using for communication.
This is now fixed and we can access this information via the OperationContext in our service implementation (or any extension in the pipeline where we already have a valid OperationContext). From there we can pull a certain message property which gets populated down in the channel layer. This property is of type RemoteEndpointMessageProperty - here is the glory code that makes it easy to print out the remote host data:
RemoteEndpointMessageProperty rep =
OperationContext.Current.IncomingMessageProperties[
RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
if (rep != null)
{
Console.WriteLine("Remote caller: {0}", rep.Address);
Console.WriteLine("Remote port: {0}", rep.Port);
}
Phil has some more information on what is going on under the cover of this.
That's it. Nothing spectacular here :)
Comments