Monday, June 15, 2009

Step 1: Communicate with a .NET Web Service

I want full control of my project and I want the ability to customize every step of my asp.net application to make the best Rich Internet App. I think JQuery is great so I wanted to use the JQuery framework in my project for everything including AJAX calls to web services. Why should I use the asp.net scripting framework if I don't want to.

Step 1: Communicating with a asp.net Web Service:
Retrieving data :

I checked out a few examples online and also experimented with the JQuery ajax API.
I wanted to use JSON as the encoding method so here is what configuration settings worked:


Important settings:
TYPE - Must always be POST if you are communicating with a web service.

URL - Must be the path to your web service followed by a forward slash and the method you are calling in your web service. In the above example I call a web service called serviceLDAP.asmx. Within the web service I call a method called ajaxLookUpCCID.

ContentType - In order to get a JSON encoded response you must specify application/json; otherwise you will receive an XML encoded response.

Below is the method that is called in the web service:



Below is the JSON encoded Response from the web service. To retrieve the value "hello" within my JQuery success function I do is alert(msg.d);


No comments:

Post a Comment