Now you're actually ready to build and test your Web service. First, build the service using the Build menu option and then start it in Debug mode. This brings up the Web service's default page generated by VS .NET in your browser, as shown in Figure 15-2.
Figure 15-2: Initially running the Web service Service1.asmx
As you can see in Figure 15-2, one method, GetOrderFromDatabase, is available in the browser.
You can make this screen a bit more descriptive by adding a WebService attribute to the top of the class and then adding descriptions to both the WebService attribute and the WebMethod attribute. As you can see, Listing 15-2 adds a description to both.
Listing 15-2: Adding Descriptions to the WebService and WebMethod Attributes
<WebService(Namespace:="http://tempuri.org/", _ Description:="Working with Orders in Northwind")> _ Public Class Service1 Inherits System.Web.Services.WebService .... <WebMethod(Description:="Retrieve an order from Northwind ")> _ Public Function GetOrderFromDatabase(_ ByVal orderID As Integer) As DataSet End Function End Class
The service now looks like Figure 15-3.
Figure 15-3: The Web service after you add attributes
If you click the link for the GetOrderFromDatabase method, you'll see a Parameter OrderID text box. Enter 10248 as the OrderID. After you click the Invoke button, the browser returns the XML data representing the DataSet, which contains the order with the order ID of 10248. Figure 15-4 shows a piece of the XML data representing the order and displayed by the browser.
Figure 15-4: The Order DataSet displayed by the browser in XML format
As you can see from Figure 15-4, the default namespace for the DataSet xmlns is http://tempuri.org. You can use the WebService attribute to specify the namespace and description text for the XML Web service. As you can see, VS .NET doesn't generate this attribute by default. You have to write it manually. If you're specifying more than one property, you can separate them with a comma. For example, the following code sets the namespace and the description properties of the WebService attribute:
<WebService(Namespace:="http://servername/xmlwebservices/", _ Description:="Working with Orders in Northwind")> _ Public Class Service1 Inherits System.Web.Services.WebService ' code here End Class