Udostępnij za pośrednictwem


How to: Add a Web Service to an Existing Web Project in Managed Code

 Windows Communication Foundation Services and ADO.NET Data Services

You can add a Web service to an existing Web project in Visual Studio.

To add a new Web service to an existing Web project

  1. In Solution Explorer, select the project to which you want to add a Web service.

  2. On the Web Site menu, click Add New Item. Alternatively, right-click the project name and point to Add New Item.

    The Add New Item dialog appears.

  3. Select Web Service, choose a name for your web service, and choose Add to add the Web service to your project.

    Visual Studio automatically creates the necessary files and references to support a Web service. When completed, the IDE displays the .asmx file in Design view. For more information, see ASP.NET XML Web Service Basics.

    You can also add an existing Web service to an existing Web project in Visual Studio. This process is limited to Web services written in the same programming language as your existing Web project. For more information, see How to: Add Existing Items to a Project.

To add an existing Web service to an existing Web project

  1. In Solution Explorer, select the project to which you want to add an existing Web service.

  2. On the Project menu, select Add Existing Item. Alternatively, right-click the project name, point to Add and then click Add Existing Item. The Add Existing Item dialog box appears.

  3. In the Files of type list, click Web Files.

  4. Select the .asmx file for the Web service you want to add.

  5. Click Open to add the Web service to your project.

    Visual Studio adds the .asmx file and its associated code-behind file to your project. For more information, see ASP.NET XML Web Service Basics.

See Also

Tasks

How to: Add New Project Items

Other Resources

Creating Web Services in Managed Code

Web Site Projects and Solutions