How to: Deploy Web Services in Managed Code

 Windows Communication Foundation Services and ADO.NET Data Services

When using Visual Studio .NET to create Web services in managed code, you use a standard deployment model: you compile your project and then you deploy the resulting files to a production server. The project .dll file contains the Web services code-behind class file (.asmx.vb or .asmx.cs) along with all other class files included in your project, but not the .asmx file itself. You then deploy this single project .dll file to the production server without any source code. When the Web service receives a request, the project .dll file is loaded and executed.

Compiling and Deploying a Web Service in Managed Code

Suppose you have a simple ASP.NET Web Service project named WebService1 that contains the following:

  • A Web service entry page named Service.asmx.

  • A code file named Service.vb (or .cs).

When you compile the project, the following occurs:

  • Visual Studio saves all of the files in the project you modified since the last build.

  • Visual Studio copies the Service1.asmx file and the default project files to the development Web server.

  • The Service.vb (or .cs) class file and the Global.asax class file are compiled into the project .dll file, which is then copied to the server in the default \bin directory of the target virtual directory. If the project is set to compile a debug version, Visual Studio creates a project .pdb file in the \bin directory.

    Note

    If compilation errors occur, the deployment will not succeed. For more information, see How to: Debug Web Services in Managed Code.

To deploy the Web service to a server other than the development server, you can add a Web Setup project or you can copy the required files to the destination server. To make your Web service available to others, you will need to deploy it to a Web server that is accessible to the clients you wish to support. For more information, see Deploying Applications and Components and How to: Copy a Project.

To deploy the Web service by copying the project

  1. In Solution Explorer, select the project you want to copy.

  2. On the Website menu, click Copy Web Site.

  3. Click the icon next to the Connect to: dropdown box to open the Open Web Site dialog box.

  4. In the Open Web Site box, select the location to which you want to copy the project.

  5. Using the arrow icons, select files from the source web site to copy to the remote web site.

  6. Click Copy Web Site to copy the web site.

After deploying your Web service, you need to consider how to make it possible for developers to locate it if you intend others to use it. For more information, see How to: Enable Discovery for XML Web Services.

See Also

Other Resources

Creating Web Services in Managed Code

Windows Installer Deployment Walkthroughs

Project Properties (Visual Studio)