The Web services can be in the form of .ASP.NET Web services (.asmx services), or Windows Communication Foundation (WCF) services (.svc services). If you have already created ASP.NET Web services (.asmx), you can modify them to enable script in your AJAX-enabled Web pages to call them. For more information, see Exposing Web Services to Client Script. If you have already created WCF services, you can add end-points to enable script in AJAX-enabled Web pages to access the services. For more information, see Exposing WCF Services to Client Script.
Calling Web Service Methods
Calling a Web service method from script is asynchronous. To get a return value or to determine when the request has returned, you must provide a succeeded callback function. The callback function is invoked when the request has finished successfully, and it contains the return value (if any) from the Web method call. You can also provide a failed callback function to handle errors. Additionally, you can pass user context information to use in the callback functions.
The following example shows how to make the following types of Web service calls:
· Calling a Web service that has no return value.
· Calling a Web service that returns a value.
· Calling a Web service method that takes parameters.
· Calling a Web service method by using the HTTP GET verb.
Calling a Web
service method that returns an XmlDocument object.