Trong thực tế, chúng ta hãy làm điều đó ngay bây giờ để chúng ta có thể gọi một dịch vụ web từ xa để có được báo giá cổ phiếu ví dụ của chúng tôi. Kích chuột phải vào tên dự án và chọn Add Reference Web. Khi Web Add | 112 CHAPTER 5 WEB SERVICES Figure 5-4. WSDL in the browser Creating the Address Service Now it s time to go beyond Hello World and provide a web service that exposes the address table from the AdventureWorks database. The web service will take a single parameter in the call the postal code that will be used to filter the desired records. Because the service requires access to data you will need to create a data connection. To do this you will use a strongly typed DataSet object in your solution. Creating this object is very straightforward. You ll look at how to use the DataSet wizard to do this in the next section. CHAPTER 5 WEB SERVICES 113 Adding Data to a Web Service To add a strongly typed DataSet to your web service you use the Solution Explorer. Right-click your project and select Add New Item. The Add New Item dialog box displays see Figure 5-5 . Figure 5-5. Adding a typed DataSet to your project Select the DataSet and give it a friendly name. To use the code later in this section for the purposes of this example you should call it AddressData. The IDE will warn you that the code should be placed in the App_Code folder. Click Yes and the TableAdapter Configuration wizard will launch. The first page of the wizard configures the desired database connection see Figure 5-6 . 114 CHAPTER 5 WEB SERVICES Figure 5-6. Configuring your database connection You can choose a configuration that is preconnected from either a known database or an existing setting as shown in Figure 5-5 . If you don t have an existing connection you can create one by clicking the New Connection button. If you want to look at the steps involved in doing this refer to Chapters 3 and 4. Once you have selected your connection click Next. This will take you to the command type configuration page see Figure 5-7 . You can choose from three options on this page. The first is to use SQL statements embedded in your code dynamic SQL which can be used to select insert