Getting your Web-Service working with HTTP.

November 11, 2006

You all must have tried consuming the web-service in .NET application by simply adding web reference to your project.

Here’s how you can make a raw HTTP request to the service.

First, make changes to the Web.config file so as to permit HTTP GET and POST requests.

<webServices>

<protocols>

<add name=”HttpGet”/>

<add name=”HttpPost”/>

</protocols>

</webServices>

Now the web service is configured to accept HTTP requests.

Make a simple console based application so as to test the above concept.

Dim http As HttpWebRequest = WebRequest.Create(“WebServiceURLString”)

http.ContentType = “application/x-www-form-urlencoded”

System.IO.StreamReader Dim stream As System.IO.StreamReader = new System.IO.StreamReader(http.GetResponse.GetResponseStream)

Console.WriteLine(stream.ReadToEnd)

‘End of Code

This is a simple way to make a HTTP request so as to access the web service.

-Bugs!

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: