![Phân tích tư tưởng của nhân dân qua đoạn thơ: Những người vợ nhớ chồng… Những cuộc đời đã hóa sông núi ta trong Đất nước của Nguyễn Khoa Điềm](https://timtailieu.net/upload/document/136415/phan-tich-tu-tuong-cua-nhan-dan-qua-doan-tho-039-039-nhung-nguoi-vo-nho-chong-nhung-cuoc-doi-da-hoa-song-nui-ta-039-039-trong-dat-nuoc-cua-nguyen-khoa-136415.jpg)
Web Services, Clients, and Proxies
Số trang: 7
Loại file: pdf
Dung lượng: 21.36 KB
Lượt xem: 14
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Dịch vụ Web, khách hàng, và proxy Bạn đã thấy rằng một dịch vụ Web sử dụng SOAP để cung cấp một cơ chế nhận được yêu cầu và gửi lại kết quả. SOAP sử dụng XML để định dạng dữ liệu được truyền qua đường, mà cưỡi trên đầu trang của giao thức HTTP được sử dụng bởi các máy chủ Web và trình duyệt.
Nội dung trích xuất từ tài liệu:
Web Services, Clients, and ProxiesWeb Services, Clients, and ProxiesYou have seen that a Web service uses SOAP to provide a mechanism for receivingrequests and sending back results. SOAP uses XML to format the data being transmitted,which rides on top of the HTTP protocol used by Web servers and browsers. This is whatmakes Web services so powerful—HTTP and XML are well understood (in theoryanyway) and are the subjects of several standards committees. SOAP itself is goingthrough the standardization process and has been adopted by most companies that want tomake their services available over the Web. A client that “talks” SOAP can communicatewith a Web service. The client and the Web service can be implemented in totallydifferent languages, running on otherwise incompatible systems. For example, aMicrosoft Visual Basic client running on a handheld device can communicate with a Webservice being hosted on an IBM 390 mainframe running UNIX.So how does a client “talk” SOAP? There are two ways: the difficult way and the easyway.Talking SOAP: The Difficult WayIn the difficult way, the client application must perform a number of steps: 1. Determine the URL of the Web service running the Web method. 2. Perform a Web Services Description Language (WSDL) inquiry using the URL to obtain a description of the Web methods available, the parameters used, and the values returned. This is an XML document. (You saw an example in the previous chapter.) 3. Convert each Web method call into the appropriate URL and serialize each parameter into the format described by the WSDL document. 4. Submit the request, along with the serialized data, to the URL using HTTP. 5. Wait for the Web service to reply. 6. Using the formats specified by the WSDL document, de-serialize the data returned by the Web service into meaningful values that your application can then process.This is a lot of work to just invoke a method, and it is potentially error-prone.Talking SOAP: The Easy WayThe bad news is that the easy way to use SOAP is not much different from the difficultway. The good news is that the process can be automated because it is largelymechanical. Many vendors supply tools that can generate proxy classes based on aWSDL description. The proxy hides the complexity of using SOAP and exposes a simpleprogrammatic interface based on the methods published by the Web service. The clientapplication calls Web methods by invoking methods with the same name in the proxy.The proxy converts these local method calls into SOAP requests and sends them to theWeb service. The proxy waits for the reply, de-serializes the data, and then passes it backto the client just like the return from any simple method call.Consuming the ProductService Web ServiceYou have created a Web service call that exposes two Web methods: GetProductInfo toreturn the details of a specified product, and HowMuchWillItCost to determine the costof buying n items of product x from Northwind Traders. In the following exercises, youwill use this Web service and create an application that consumes these methods. Youllstart with the Get- ProductInfo method.Create a Web service client application 1. Start another instance of Visual Studio 2005. This is important. The ASP.NET Development server stops if you close the NorthwindServices Web service project, meaning that you wont be able to access it from the client (an alternative approach you can use is to create the client application as a project in the same solution as the Web service). When you host a Web service in a production environment by using IIS, this problem does not arise because IIS runs independently from Visual Studio 2005. 2. In the second instance of Microsoft Visual Studio 2005, create a new project using the Windows Application template. Name the project ProductInfo and save it in the \Microsoft Press\Visual CSharp Step By Step\Chapter 28 folder in your My Documents folder. 3. Change the filename of the Form1.cs file to ProductForm.cs. 4. Change the size of the form to 392, 400. Set its Text property to Product Details. 5. Add 10 labels to the form, evenly spaced down the left side. From top to bottom, set the Text property of each label using the following values: Product Name, Product ID, Supplier ID, Category ID, Quantity Per Unit, Unit Price, Units In Stock, Units On Order, Reorder Level, and Discontinued. 6. Add nine text boxes to the form adjacent to the first nine labels. Clear the Text property for each text box. Set the Name property of each text box from top to bottom using the following values: productName, productID, supplierID, categoryID, quantityPerUnit, unitPrice, unitsInStock, unitsOnOrder, and reorderLevel. 7. Add a check box to the form next to the Discontinued label and below the reorderLevel text box. Set its Name property to discontinued, and then clear its Text property. 8. Add a button to the form, to the right of the productName text box. Change the name of the button to getProduct, and then set its Text property to Get Product. The completed form should look like the following graphic:Add a reference to the Web service 1. On the Project menu, click Add Web Reference. The Add Web Reference dialog box opens. This dialog box allows you to browse for Web services and examine the WSDL descriptions. 2. Type the URL of the NorthwindServices Web service in the Address text box at the top of the dialog box: http://localhost:4500/NorthwindServices/Service.asmx. Click Go. TIP If the Web service is hosted by IIS on your computer, you can click the “Web services on the local machine” hyperlink in the left pane of the dialog box rather than typing the ...
Nội dung trích xuất từ tài liệu:
Web Services, Clients, and ProxiesWeb Services, Clients, and ProxiesYou have seen that a Web service uses SOAP to provide a mechanism for receivingrequests and sending back results. SOAP uses XML to format the data being transmitted,which rides on top of the HTTP protocol used by Web servers and browsers. This is whatmakes Web services so powerful—HTTP and XML are well understood (in theoryanyway) and are the subjects of several standards committees. SOAP itself is goingthrough the standardization process and has been adopted by most companies that want tomake their services available over the Web. A client that “talks” SOAP can communicatewith a Web service. The client and the Web service can be implemented in totallydifferent languages, running on otherwise incompatible systems. For example, aMicrosoft Visual Basic client running on a handheld device can communicate with a Webservice being hosted on an IBM 390 mainframe running UNIX.So how does a client “talk” SOAP? There are two ways: the difficult way and the easyway.Talking SOAP: The Difficult WayIn the difficult way, the client application must perform a number of steps: 1. Determine the URL of the Web service running the Web method. 2. Perform a Web Services Description Language (WSDL) inquiry using the URL to obtain a description of the Web methods available, the parameters used, and the values returned. This is an XML document. (You saw an example in the previous chapter.) 3. Convert each Web method call into the appropriate URL and serialize each parameter into the format described by the WSDL document. 4. Submit the request, along with the serialized data, to the URL using HTTP. 5. Wait for the Web service to reply. 6. Using the formats specified by the WSDL document, de-serialize the data returned by the Web service into meaningful values that your application can then process.This is a lot of work to just invoke a method, and it is potentially error-prone.Talking SOAP: The Easy WayThe bad news is that the easy way to use SOAP is not much different from the difficultway. The good news is that the process can be automated because it is largelymechanical. Many vendors supply tools that can generate proxy classes based on aWSDL description. The proxy hides the complexity of using SOAP and exposes a simpleprogrammatic interface based on the methods published by the Web service. The clientapplication calls Web methods by invoking methods with the same name in the proxy.The proxy converts these local method calls into SOAP requests and sends them to theWeb service. The proxy waits for the reply, de-serializes the data, and then passes it backto the client just like the return from any simple method call.Consuming the ProductService Web ServiceYou have created a Web service call that exposes two Web methods: GetProductInfo toreturn the details of a specified product, and HowMuchWillItCost to determine the costof buying n items of product x from Northwind Traders. In the following exercises, youwill use this Web service and create an application that consumes these methods. Youllstart with the Get- ProductInfo method.Create a Web service client application 1. Start another instance of Visual Studio 2005. This is important. The ASP.NET Development server stops if you close the NorthwindServices Web service project, meaning that you wont be able to access it from the client (an alternative approach you can use is to create the client application as a project in the same solution as the Web service). When you host a Web service in a production environment by using IIS, this problem does not arise because IIS runs independently from Visual Studio 2005. 2. In the second instance of Microsoft Visual Studio 2005, create a new project using the Windows Application template. Name the project ProductInfo and save it in the \Microsoft Press\Visual CSharp Step By Step\Chapter 28 folder in your My Documents folder. 3. Change the filename of the Form1.cs file to ProductForm.cs. 4. Change the size of the form to 392, 400. Set its Text property to Product Details. 5. Add 10 labels to the form, evenly spaced down the left side. From top to bottom, set the Text property of each label using the following values: Product Name, Product ID, Supplier ID, Category ID, Quantity Per Unit, Unit Price, Units In Stock, Units On Order, Reorder Level, and Discontinued. 6. Add nine text boxes to the form adjacent to the first nine labels. Clear the Text property for each text box. Set the Name property of each text box from top to bottom using the following values: productName, productID, supplierID, categoryID, quantityPerUnit, unitPrice, unitsInStock, unitsOnOrder, and reorderLevel. 7. Add a check box to the form next to the Discontinued label and below the reorderLevel text box. Set its Name property to discontinued, and then clear its Text property. 8. Add a button to the form, to the right of the productName text box. Change the name of the button to getProduct, and then set its Text property to Get Product. The completed form should look like the following graphic:Add a reference to the Web service 1. On the Project menu, click Add Web Reference. The Add Web Reference dialog box opens. This dialog box allows you to browse for Web services and examine the WSDL descriptions. 2. Type the URL of the NorthwindServices Web service in the Address text box at the top of the dialog box: http://localhost:4500/NorthwindServices/Service.asmx. Click Go. TIP If the Web service is hosted by IIS on your computer, you can click the “Web services on the local machine” hyperlink in the left pane of the dialog box rather than typing the ...
Tìm kiếm theo từ khóa liên quan:
ngôn ngữ lập trình lập trình ngôn ngữ C# C# Clients and ProxiesTài liệu liên quan:
-
Giáo trình Lập trình hướng đối tượng: Phần 2
154 trang 282 0 0 -
Kỹ thuật lập trình trên Visual Basic 2005
148 trang 279 0 0 -
Bài thuyết trình Ngôn ngữ lập trình: Hệ điều hành Window Mobile
30 trang 275 0 0 -
Giáo trình Lập trình cơ bản với C++: Phần 1
77 trang 235 0 0 -
Bài giảng Một số hướng nghiên cứu và ứng dụng - Lê Thanh Hương
13 trang 231 0 0 -
NGÂN HÀNG CÂU HỎI TRẮC NGHIỆM THIẾT KẾ WEB
8 trang 223 0 0 -
Giáo án Tin học lớp 11 (Trọn bộ cả năm)
125 trang 219 1 0 -
Bài tập lập trình Windows dùng C# - Bài thực hành
13 trang 194 0 0 -
Bài giảng Nhập môn về lập trình - Chương 1: Giới thiệu về máy tính và lập trình
30 trang 176 0 0 -
Giáo trình Lập trình C căn bản: Phần 1
64 trang 170 0 0