I have been a huge fan of web services over the years, mainly due to the strong coupling with ASP.NET, the familiar coupling of HTTPContext (request and response) when I needed access to information being sent to the server in the typical HTTP headers. During my recent work with Visual Studio 2010 (.NET 4.0) I immediately started using the Windows Communication Foundation (WCF) projects as the primary means for developing service oriented API for my Windows Phone 7 apps.

One of the first things I realized I missed was the obvious connection to the HTTPContext information (IP Address, Port, etc.). There is, however, a means to get at similar information with scope of a WCF project as follows:

OperationContext op = OperationContext.Current;

MessageProperties mpa = op.IncomingMessageProperties;
var epp = mpa[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;

string address = epp.Address;
int port = epp.Port;

These properties were made available to us during version .NET 3.5, I have also had a couple of chances to integrate and HttpRequestMessageProperty which gives us direct access to things like HTTP Method (GET, POST, etc.), Headers and QueryString.