Building XML Web Services for the Microsoft .NET Platform phần 10

Ví dụ, nhớ lại rằng các dịch vụ Web Ngân hàng cho thấy nhiều phương pháp Web GetStockQuote. Giả sử các trích dẫn nội dung bài viết này nhận được từ dịch vụ Web có thể được trì hoãn đến 20 phút. Ví dụ sau đây minh họa việc sử dụng tài sản | You can configure the cache using the CacheDuration property exposed by the WebMethod attribute. For example recall that the Banking Web service exposes the GetStockQuote Web method. Suppose the quote received from the Web service can be delayed up to 20 minutes. The following example illustrates the use of the CacheDuration property using System using public class Banking WebMethod CacheDuration 1200 public double GetStockQuote string symbol double price 0 Obtain the current price for the security. return price When a request for a particular security is received the Web method returns the price of the security. Because the CacheDuration property is set if a request for the same security is received in the next 20 minutes 1200 seconds the runtime will not invoke the GetStockQuote Web method. Instead it will return the cached response to the client. Sometimes it is not practical to cache the entire SOAP response returned from a Web method. However you might have opportunities to cache discrete pieces of data used within the implementation of a Web method. For these situations the runtime provides a more generic caching mechanism. Recall that the Banking Web service charges a fee based on the amount transferred. Suppose the fee charged to the customer for performing the wire transfer is maintained in an XML document similar to the one shown here xml version Fees Fee minExclusive 0 maxInclusive 100 .50 Fee Fee minExclusive 100 maxInclusive 250 Fee Fee minExclusive 250 maxInclusive 500 Fee Fee minExclusive 500 maxInclusive 1000 Fee Fee minExclusive 1000 maxInclusive 999999 Fee Fees The document contains a list of fees based on the amount transferred. The implementation of the RequestWireTransfer method uses the data in the XML document to determine the fee that should be charged to the client. using System 344 using using using public class Banking WebMethod

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
103    140    5    10-05-2024
78    79    1    10-05-2024
Đã 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.