

What’s good about the HttpWebRequest is that you have complete control over everything that’s sent to the Web Service. But, even with those steps omitted, that’s a lot of code. I’ve left some important steps out of here: I haven’t, for example, provided any credentials to log into the service in C# the conversion of the returned data (the string "false") to a Boolean would be more complicated and the WebResponse has a Dispose method that I should be calling through a Using block. If CType(wr, HttpWebResponse).StatusCode = HttpStatusCode.OK Then Listing 1: Calling a RESTful Service Using HttpWebRequest Listing 1 shows the simplest possible request using the HttpWebRequest object: a call to a single Web Service method, passing a single parameter ("Vogel"), and getting back a single, Boolean result.

The issue with the HttpWebRequest is that, if you want to call a RESTful service with the HttpWebRequest, you’re going to have to specify everything yourself. Each has its costs and benefits (of course), so this column is about why you might choose each one.įor me, the HttpWebRequest is primarily of "historical interest" - it’s the earliest of the tools to appear (as I remember) and is also the least "developer-friendly" of the three objects. NET Framework gives you three objects you can use to make the call: HttpWebRequest, WebClient and HttpClient.

If you’re going to call a RESTful Web Service, the.
