Share via


Walkthrough: Designing a Web ServiceĀ 

This walkthrough illustrates key aspects of designing a Web service using Application Designer. This walkthrough explains how to:

  • Define operations on an existing Web service.

  • Implement the Web service.

  • Add an external Web service (a Web service outside the solution) and view Web methods on it.

  • Connect the external Web service to other applications.

This walkthrough builds on concepts presented in the introductory walkthrough topic, Walkthrough: Defining Applications.

To define operations on the Catalog Web service

  1. Load the sample provided at https://go.microsoft.com/fwlink/?LinkId=40867.

  2. Open Catalog.ad in Application Designer.

  3. Select the CatalogWebService endpoint on Catalog and view the Web Service Details window.

  4. In the Web Service Details window, click <add operation> and type "GetProductDetails".

  5. Under Type, enter "ProductDetails". The type you enter here specifies the return type of the operation.

  6. Expand plus sign (+) to the left of GetProductDetails to add parameters to the operation.

  7. Click <add parameter> and type "ProductNumber". Under Type, enter Integer.

    Note

    When you begin typing in the Type column, Visual Studio provides a list of available types.

    This operation takes an integer product number and returns a ProductDetails structure.

    The defined operation is request-response by default. For more information about how to change this property, see How to: Specify One-Way or Request-Response Operations for ASP.NET Web Services.

To set project properties and implement the Catalog Web service

  1. Select the CatalogWebService endpoint on the Catalog application.

  2. View the Properties window.

  3. Edit the WSDL Binding Name property to be "Catalog".

  4. Edit the WSDL Binding Namespace property to be https://Adventureworks/Products.

  5. Select the Catalog application.

  6. Set the Language property to Visual C#.

    Note

    If you installed all languages with Visual Studio, the value of this property defaults to Visual Basic.

  7. With the Catalog application selected, on the Diagram menu choose Implementation and then Implement Application.

    The Confirm Application Implementation dialog box appears.

  8. Review the implementation details for the Catalog application and click OK.

    The implementation process generates a project for the application with the appropriate Web references. Once implementation is complete, the application displays with a drop shadow.

    Note

    When the Security Warning dialog box appears, click Close. This dialog box indicates that the database connection string for the database on the application diagram is being written to the configuration file unencrypted and in plain text.

  9. Review the proxy classes and Web reference in Solution Explorer.

  10. Open the CatalogWebService.cs file and view the code for the ProductDetails WebMethod.

    Notice that the WSDL Binding Name and Namespace have been set and the method signature has been created.

  11. In code, change the operation name from GetProductDetails to GetProductInformation.

  12. Select the CatalogWebService endpoint and view the Web Service Details window.

    The operation name has changed in the Web Service Details window to reflect the change made to the WebMethod signature in code. Any changes made in code are automatically reflected in the Web Service Details window and vice versa.

To add an external Web service and view Web methods

  1. Open the Toolbox and drag an ExternalWebService to the application diagram.

    The Add Web Reference dialog box appears.

  2. Find the location of LegacyCatalog.wsdl on your local machine.

  3. In URL, enter this location and click Go.

    The description of the WSDL file appears along with the method it defines.

  4. Click Add Reference.

    The external Web service appears on the application diagram.

  5. Select the GetLegacyInfo endpoint and view the Web Service Details window by choosing Other Windows and then choosing Web Service Details from the View menu.

  6. Examine the Web method displayed in the Web Service Details window.

    This particular WSDL file contains methods for accessing information in a legacy catalog.

To connect the external Web service with the Catalog Web service

  • Select the GetLegacyInfo endpoint on the external Web service, press ALT and drag to the border of the Catalog application.

    This action creates a consumer endpoint on Catalog, indicating that the Catalog application consumes services provided by LegacyInfo. When the Catalog application is implemented, proxy classes will be generated for the Web methods defined on the GetLegacyInfo endpoint.

    An .sdm file for the external Web service is also added to the solution. This file contains SDM definitions for this application. For more information, see Overview of the System Definition Model (SDM).

Next Steps

The next step is to work more with Web service endpoints. For more information, see Walkthrough: Contract Driven Web Service Design - Creating an Endpoint.

See Also

Other Resources

Designing Web Services Walkthroughs