Accessing a WCF service via the WebRequest component
Sometimes, it is required that our WCF service be called by some client platform which can only issue plain HTTP GET/POST requests. Or, in .NET framework-based applications, we sometimes might need to use WebRequest
components (under the
System.Net
namespace) to consume XML Web Services or WCF services.
In this recipe, we will demonstrate how to use a .NET WebRequest
component to consume an HTTP-based WCF service.
How to do it...
Here we will use a HttpWebRequest component to retrieve some simple text data from a standard WCF service application. Let's take a look at the steps to achieve this:
- Set up the WCF service application.
The sample service here is a very simple one that contains one operation ...
Get Microsoft Windows Communication Foundation 4.0 Cookbook for Developing SOA Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.