Monday, August 17, 2009

How to Access an XML Web Service Using HTTP-GET Protocol


A web service is a proxy between a web application and the internal process. For instance, a web service retrieves commands and queries the internal database for results. The result set is then distributed back to the web application in the form of XML. Before accessing the web service using "get," settings are needed on the web service server.


  1. Step 1

    Open the web.config file in the Visual Studio. A web.config file is specific to the web application, so the project needs to be loaded.

  2. Step 2

    Enter the following code into the protocol XML tag. This allows the web service application to accept incoming "get" calls from a remote client. The code below also shows how to configure the web service for "post" calls.

  3. Step 3

    Enter settings in the machine.config file. The difference between the web.config and the machine.config is that machine.config is a global solution. Settings entered into this file affect all applications. Using a web.config only changes settings for that specific web service. The code below is placed in the machine.config file in the protocol tabs. Machine.config is located in the C:\Windows\Microsoft.NET\Framework\\config directory. The "" is the .NET version used on the web server.




    This code snippet allows access from the local host for SOAP, post, and get calls.

  4. Step 4

    Test the settings. Open a web browser and navigate to the web service using the "get" call. The get call is conducted through the query string in the browser. For instance, localhost/webservice/service.asmx?function=load&firstname=stacy is a get call to the web service. The function and first name variables are picked up by the web service "get" procedure and processed for results.

No comments:

Post a Comment