Creating an XML Web Service Contract
As we discussed in Hour 3, an XML Web service is defined using a WSDL contract. This WSDL contract file is then used by .NET to create proxy classes that allow client applications to interface with the XML Web service. You will build your first proxy class in Hour 8 when you create a client-side interface for the Four-Function Calculator.
Creating the WSDL file is extremely easy. If you look back at Figure 7.3, you will see a link to the WSDL file near the top of our ASMX file labeled Service Description. If you click on this link, the entire WSDL file will be opened in Internet Explorer. Figure 7.6 shows a portion of the WSDL file used to define the calculator service. Simply save this file to disk as Service1.WSDL and you are done. Client applications can now be developed that use your XML Web service.
Figure 7.6 This WSDL file acts as a contract between the Four-Function Calculator and client applications.
When you deploy your service on a different server, you will have to create a new WSDL contract file because the complete path of your service is listed in the WSDL. In Figure 7.6, you can see the path to the FourFunctionCalc listed in SOAP <address> space. Failure to create a new SDL file may cause a client application to point to the wrong server and thus cause your XML Web service to fail.