Deploying web services is similar to deploying web pages, which will be covered in detail in Chapter 19. The .asmx file must be located in a virtual directory exposed by IIS so it is accessible to a browser on the Internet. If you have a .disco file for the web service (described in the previous section), then this file should also be in the application virtual directory. This allows the web service to be discovered and allows proxies to be created by consuming applications. Both of these concepts will be described in the next chapter.
If the application requires a web.config file (described fully in Chapter 18), then this file too should be copied to the application virtual directory.
As with web pages, you can make the compiled class (or classes) and other resources available with either pre-compiled assemblies or with dynamically compiled assemblies.
The technique from prior versions of Visual Studio, which is still fully supported, is to compile the source code manually into an assembly file (i.e., the dll ) and locate that in the bin directory immediately beneath the virtual directory containing the .asmx file. Manual compilation of assemblies is described in the next chapter and in Chapter 19.
Figure 15-11 shows a typical directory structure on a production web server for a web service called StockTicker .
Referring to Figure 15-11, if a virtual directory was defined on the web server called StockTicker , which was mapped to the directory called StockTicker (the name of the virtual directory and the physical directory do not have to be the same), then the URL for referring to the .asmx file would be the following:
http://YourDomain.com/StockTicker/StockTicker.asmx
The .NET Framework automatically compiles any source code found in the \App_Code directory under the web application virtual root. VS2005 cooperates in this by automatically creating the \App_Code folder when it creates a new web service, and placing the code-behind file there. Every time the web app is started, any code found in the \App_Code folder is compiled into an assembly and cached.
The virtual directory and the URL used to access the web service would be the same, as shown in the previous section.