O'Reilly logo

Microsoft Windows Communication Foundation 4.0 Cookbook for Developing SOA Applications by Steven Cheng

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting the IP address of a client consumer of a WCF service

When developing those network hosting services (over HTTP or TCP), it is useful to get the IP address of the client-side callers/consumers so as to perform some counting or analysis work. Started from .NET Framework 3.5, WCF also provides built-in interfaces for service developers to conveniently get the IP address of client consumers of certain WCF services/endpoints. We can get the IP address of a client consumer as long as the underlying transport protocol is HTTP or TCP based (such as WSHttpBinding, NetTcpBinding, BasicHttpBinding, and so on).

How to do it...

  1. Get a reference to the message properties from OperationContext.

    The IP address information is embedded in the message properties ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required