Danh mục

Viewing a WSDL File and Testing a Web Service

Số trang: 7      Loại file: pdf      Dung lượng: 48.02 KB      Lượt xem: 1      Lượt tải: 0    
10.10.2023

Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Xem một tập tin WSDL và thử nghiệm một dịch vụ web WSDL là viết tắt của Web Ngôn ngữ mô tả dịch vụ, và một tập tin WSDL chứa một mô tả đầy đủ các dịch vụ Web của bạn, bao gồm các thông tin cần thiết để gọi các phương pháp của dịch vụ. Một tập tin WSDL được viết bằng XML và quy định cụ thể các thông tin sau
Nội dung trích xuất từ tài liệu:
Viewing a WSDL File and Testing a Web ServiceViewing a WSDL File and Testing a Web ServiceWSDL stands for Web Services Description Language, and a WSDL file contains acomplete description of your Web service, including the information required to call yourservices methods. A WSDL file is written in XML and specifies the followinginformation: • Web service methods • Data types used by the methods • Request and response message formats for communication with the methodsNote For comprehensive information on WSDL, visit www.w3.org/TR/wsdl.You access your Web service by pointing your browser to the following URL:http://localhost/NorthwindWebService/Customers.asmxAs you can see from Figure 17.3, the resulting page displayed in your browser containstwo links named Service Description and Retrieve Customers.Figure 17.3: Accessing a Web serviceNote You can also access your Web service by right-clicking on the Customers.asmx file in the Solution Explorer window in VS .NET and selecting Set As Start Page from the pop-up menu. You then select Debug ➣ Start Without Debugging to test your service. VS .NET will start Internet Explorer and display the same test page as was shown in Figure 17.3.Viewing the WSDL File for the Web ServiceIf you click the Service Description link, youll see the description of your Web service inthe form of a WSDL file, which is shown in Listing 17.3. Notice that this WSDL file iswritten in XML and contains the details on how to call the methods exposed by theexample Web service. The WSDL file also contains the data types of the parameters usedand the calls you can make to your methods.Listing 17.3: WEB SERVICE WSDL FILE location=http://localhost/NorthwindWebService/Customers.asmx /> Next, youll see how to test your Web service.Testing a Web ServiceTo test your Web service, point your browser to the following URL:http://localhost/NorthwindWebService/Customers.asmxClick the Retrieve Customers link. Your browser displays a page (see Figure 17.4) thatyou can use to test the RetrieveCustomers() method exposed by your Web service.Figure 17.4: The Web service test pageThe test page contains a text box with a label of whereClause where you can enter valuesfor the whereClause parameter of your RetrieveCustomers() method. The text you enterfor your whereClause is passed to the RetrieveCustomers() method when you click theInvoke button on the page. Enter the following text as your whereClause:CustomerID=ALFKIClick the Invoke button to run the RetrieveCustomers() method. With this whereClause,the RetrieveCustomers() method returns a DataSet with a DataTable containing the onerow from the Customers table with a CustomerID of ALFKI, as shown in Figure 17.5.Notice that the equals (=) and single quote () characters in the whereClause parametervalue of the URL have been converted to the codes %3D and %27 respectively.Figure 17.5: Running the RetrieveCustomers() method with a whereClause ofCustomerID= ALFKIAs you can see from Figure 17.5, the DataSet is returned as an XML document. You canuse this XML in your client programs that use the Web service. Youll see how to write aclient program in the next section.Lets take a look at another example; enter the following string as your whereClause andclick the Invoke button:CustomerID IS NOT NULLThis causes the RetrieveCustomers() method to return a DataSet with a DataTablecontaining all the rows from the Customers table (see Figure 17.6). Notice that the spacecharacters in the whereClause parameter value have been converted to plus (+)characters. Youll need to scroll down the page to see the other customers.Figure 17.6: Running the RetrieveCustomers() method with a whereClause ofCustomerID IS NOT NULLNext, youll see how to use your Web service in a Windows application.

Tài liệu được xem nhiều: