Export (0) Print
Expand All

Deploying XML Web Services in Managed Code

When using Visual Studio .NET to create XML 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 XML 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 XML Web service receives a request, the project .dll file is loaded and executed.

Compiling and Deploying an XML Web Service in Managed Code

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

  • An XML Web service entry page named Service1.asmx.
  • Some additional modules, named Service1.vb (or .cs) and BusinessLogic.vb (or .cs), which contain business logic.

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 Service1.asmx.vb (or .asmx.cs) class file, the Global.asax class file, and the BusinessLogic.vb (.cs) 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 Debugging XML Web Services in Managed Code.

To deploy the XML 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 XML 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 Copying a Project.

To deploy the XML Web service using a Web Setup project

  1. On the File menu, point to Add Project and then click New Project.
  2. Select the Setup and Deployment Projects folder and then click Web Setup Project.
  3. In the Name box, type a name for your deployment project and then click OK.
  4. In Solution Explorer, right-click the deployment project. On the shortcut menu, point to Add, and then click Project Output.
  5. In the Add Project Output Group dialog box, select Primary output, Debug Symbols, and Content Files. For more information, see Adding and Removing Project Outputs in the File System Editor.
    • The Primary output group consists of the project .dll file and its dependencies.
    • The Debug Symbols group consists of the project PDB file.
    • The Content Files group consists of the remaining files for the XML Web service, such as the .asmx, .asax, and .config files.
  6. Click OK.

To deploy the XML Web service by copying the project

  1. In Solution Explorer, select the project you want to copy.
  2. On the Project menu, click Copy Project.
  3. In the Destination project folder box, enter the location to which you want to copy the project.
  4. Select either FrontPage or File share to select a Web access method. For more information, see Changing Web Project Access Methods.
  5. Select Only files needed to run this application.
  6. Click OK.

After deploying your XML 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 Fine-Tuning Discovery Mechanisms.

See Also

Creating XML Web Services in Managed Code | Deployment Walkthroughs | Managing Projects

Show:
© 2014 Microsoft