How to use asp.net ajax to access Web SERVICES/WCF Services

Source: Internet
Author: User
Tags web services

Web Services

Use client script to invoke ASP.net Web services (. asmx) and Windows Communication Foundation (. svc). Script references are automatically added to the page, And they automatically generate Web service proxy classes, where you use client script to invoke Web service.

You can also access the ASP.net web servicce do not use asp.net AJAX server-side controls (if you use a different web development environment, for example). So you can do this on the page, including referencing the Microsoft AJAX Library, referencing the script file, and the corresponding own Web service. At run time, ASP. NET generates the proxy class invocation service.

asp.net Web Services is a method invocation http under a component. Below you learn how to create a Web service and how to use client script to invoke Webserice in a ajax-enabled Web application.

Using Web Services in asp.net AJAX

In fact, ASP.net Ajax uses client script to invoke the service, which has its own defined services as well as built in application services. The application services are also available in ASP.net AJAX and include authentication, roles, and Profile services.

The ASP.net Web services also customizes the creation of Web services, or Windows Communication Foundation (. SVC services).

One: Use the scene:

You use WCF and asp.net have the following case:

A: If you have created a WCF service, you can add access to the ajax-enabled Web pages that enter the terminal,

B: If you have created ASP.net Web (. asmx) services, you can modify them to allow access to the same service using scripting.

C: If you want to use ASP.net AJAX Web pages, use scripting to access custom services you create yourself. You can implement it like a WCF service or an asp.net Web service sample.

D: You can use the services built by ASP.net application to access the Ajax-enabled Web page user's authentication, roles, and profile.

Second: Background

Communication on the page uses a Web service communication layer, using AJAX technology to generate Web service calls. Data is exchanged asynchronously at the client and server side, especially in JSON format.

(1) Client-server Communication for AJAX Clients

On ajax-enabled Web pages, the browser manufactures an initialization request to the server and asynchronously requests Web services for the data. The main element of customer communication is to download the proxy class and core Client-script from the server side Library. The main elements of server-side communication are handlers and custom services. The following picture shows how the elements are invoked when they communicate between the server and the client.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.