How to: Define Operations for ASP.NET Web Services 

In Application Designer, you can define operations and their parameters for a Web service provider endpoint on an ASP.NET application using the Web Service Details window. You can also define operations by creating a Web service provider endpoint on the ASP.NET application using a specified WSDL or .disco file. This action creates an endpoint with predefined operation signatures and types based on the WSDL or .disco file used and that you can then edit in the Web Service Details window. For more information, see Overview of ASP.NET Applications on Application Diagrams and How to: Add Endpoints to Applications.

Once the application is implemented, a Web service class file exists in the application project for each Web service provider endpoint on the application. Each Web service class file contains the operation signatures for the corresponding Web service provider endpoint. Each operation signature, along with any comments, appears as a method with the WebMethod attribute in the Web service class file. You can then add the appropriate method body code to complete the implementation of each operation.

After defining operations, you can edit them at any time using the Web Service Details window. After the application is implemented, you can edit operations through the Web Service Details window or through the code, which are kept synchronized. For more information, see How to: Edit Operations for ASP.NET Web Services.

To define a Web service operation

  1. On the diagram, select a Web service provider endpoint on an ASP.NET application.

  2. On the Diagram menu, choose Define Operations.

    Tip

    You can also right-click the endpoint to choose Define Operations.

    The Web Service Details window appears.

  3. On the operation row in the Web Service Details window, click <add operation> under Name and name the operation.

  4. On the same row under Type, specify the operation return type, if needed. If you do not need to specify a type, proceed to Step 7.

    Note

    By default, an operation returns no data unless explicitly defined to do so. The representation of an operation that returns no data depends on the language specified for the Web service. When using Visual Basic, no operation return type is specified. When using Visual C# or Visual J#, the default return type for an operation is void. Interface types cannot be serialized and will generate an error when creating any Web references connected with the Web service.

  5. To select a type, begin typing to view the type list.

    As you type, the list opens and displays available types.

    Tip

    If the type you want is not in the type list, use the fully qualified type name, specify a type defined in another project or type library, or specify a new type to define after implementation. To finish specifying the type, continue typing the name of the type you want.

  6. Leave the cell by pressing ENTER or clicking another cell.

    Note

    Pressing the TAB key replaces the type you specified with the closest matching type in the type list.

  7. Under Summary, add any comments about the operation.

    Tip

    To add more information, click the ellipsis () button to open the Description dialog box. You can then specify additional comments for the WSDL description, the operation return type, if any, and other remarks. Any WSDL description information that you specify appears in the WSDL file.

Before an ASP.NET application is implemented, the type list displays only those types that are defined in the Microsoft core library (MSCorLib.dll) plus a number of other implicitly referenced type libraries. However, you can reference types defined in other type libraries and projects, or you can reference types that you plan to define at a later time in code or by using Class Designer once the application is implemented.

If you reference types that are defined in other projects or type libraries, you must add references to those projects or libraries once the application is implemented. The type list will include all types that are defined in all explicitly referenced projects and type libraries. For more information, see How to: Add and Remove References in Visual Studio (C#, J#).

If you reference types that you plan to define later, these types do not appear in the type list until you add a class file or class diagram to the application project to define the type once the application is implemented. For more information, see How to: Define Operation and Parameter Types for ASP.NET Web Services.

After you define an operation, you can define its parameters or another operation on the next operation row.

To define parameters for a Web service operation

  1. In the Web Service Details window, expand the operation node.

  2. On the parameter row below the operation, click <add parameter> under Name and name the parameter.

    Tip

    Choose a unique parameter name within the operation.

  3. Under Type, specify the parameter type if needed.

  4. Under Modifier, select how to pass the parameter.

  5. Under Summary, add any comments about the parameter.

    Tip

    To add more information, click the ellipsis () button to open the Description dialog box.

After defining a parameter, you can define a new parameter on the next parameter row. You can also define a parameter through its properties in the Properties window.

See Also

Tasks

How to: Specify One-Way or Request-Response Operations for ASP.NET Web Services
How to: Edit Operations for ASP.NET Web Services
How to: Delete Operations and Parameters from ASP.NET Web Services

Reference

Keyboard Shortcuts for the Web Service Details Window

Other Resources

Defining Operations for ASP.NET Web Services