Chapter 11. Working with HTTP
One of the benefits of programming in the world of REST is the ability to take advantage of the maturity of HTTP and the established infrastructure of the Web. To do this successfully in a programming environment, you need access to the underlying HTTP constructs so that you can modify HTTP headers programmatically and take full advantage of this rich platform.
In this chapter, you will learn how WCF exposes the world of HTTP through its programming model, along with the most common ways you’ll likely end up interacting with HTTP.
Programming HTTP with WCF
I introduced the WCF HTTP programming model in Chapter 2. Whenever you are using HTTP
with WCF, you can ask for the current
WebOperationContext object through the
WebOperationContext.Current static property. The first time you ask for this property, a new instance of
WebOperationContext object is created and attached
to the current WCF generic
OperationContext object. On
subsequent property accesses, of course, the already-created instance is
I should reiterate that WCF automatically modifies the HTTP
requests and responses based on the
definition. An operation’s
WebInvokeAttribute tell WCF a lot about what to do
with HTTP requests and responses. The URI and the HTTP method are
completely influenced by that mechanism.
The HTTP context I will discuss in this chapter illustrates how to go beyond that base functionality.
WebOperationContext is the WCF wrapper ...