tailieunhanh - ASP.NET AJAX Programmer’s Reference - Chapter 14

Consuming Web Ser vices Via JSON Messages Như bạn đã thấy trong chương trước, bạn có thể sử dụng XMLHttpExecutor, WebRequestManager, và các lớp WebRequest để làm cho các yêu cầu đến máy chủ. Tuy nhiên, phương pháp này đòi hỏi bạn phải viết rất nhiều mã để tạo ra một yêu cầu. -Bên khuôn khổ AJAX khách hàng bao gồm một WebServiceProxy lớp có tên là gói gọn tất cả các logic sử dụng XMLHttpExecutor, WebRequestManager, và các lớp WebRequest để tạo ra một yêu cầu đến máy chủ. Điều này cho phép bạn thực hiện một yêu. | 14 Consuming Web Services Via JSON Messages As you saw in the previous chapter you can use the XMLHttpExecutor WebRequestManager and WebRequest classes to make requests to the server. However this approach requires you to write lot of code to make a request. The AJAX client-side framework includes a class named WebServiceProxy that encapsulates all the logic that uses the XMLHttpExecutor WebRequestManager and WebRequest classes to make a request to the server. This enables you to make a request with minimal time and effort. The downside of the WebServiceProxy approach is that it supports only JSON messages. If you need to use normal SOAP messages to communicate with a Web service you have to use the techniques discussed in the previous chapter. This chapter begins by discussing the important members of the WebServiceProxy class. WebServiceProxy As you can see in Listing 14-1 the constructor of the WebServiceProxy class doesn t do anything. Listing 14-1 The Constructor of the WebServiceProxy Class function Sys Net WebServiceProxy Timeout The WebServiceProxy class exposes a getter named get_timeout and a setter named set_timeout that enable you to get and set the request timeout as shown in Listing 14-2. Chapter 14 Consuming Web Services Via JSON Messages Listing 14-2 Getting and Setting the Request Timeout function Sys Net WebServiceProxy set_timeout value value function Sys Net WebServiceProxy get_timeout return Default Succeeded Callback You call the set_defaultSucceededCallback method on the WebServiceProxy object to specify a JavaScript function as the default succeeded callback for Web requests see Listing 14-3 . As the name implies this JavaScript function is automatically invoked when a request is completed successfully. You call the get_defaultSucceededCallback method on the WebServiceProxy object to return a reference to the JavaScript .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.