Chapter 10. Consuming RESTful XML Services Using WCF
One important feature of WCF is that the server and client programming models are symmetrical. Unlike earlier
technologies such as ASMX, a WCF service is defined the same way a WCF
client is defined (i.e., via
ServiceContract et al.).
There is no notion in WCF of a “service binding”; there are just bindings.
Bindings are used on both listening endpoints (the service) and sending
endpoints (the client).
WCF 3.5 and its Web Programming Model do not change this fundamental fact concerning WCF. As in all other parts of WCF, the Web Programming Model works on the client in exactly the same way it works on the server. Throughout most of this book, we have focused on how to create RESTful services using WCF, and most of the time we’ve been using a browser or a raw-HTTP API to consume those services. Using a browser or a raw-HTTP API provides a big advantage to RESTful services in general, but it is sometimes useful to have an abstraction on top of the client programming model. In this chapter we’ll explore how to use the WCF Web Programming Model to consume RESTful services.
Defining the Client
Unlike SOAP-based services that often expose metadata (via WSDL or Mex), RESTful services don’t have any inherent metadata. This means that creating RESTful clients is generally a manual process.
Many people look at the lack of metadata as one of the big downsides of REST. Others look at the lack of metadata as an upside of REST, since it makes ...