Share via


Walkthrough: Creating Substitutable Web Services

This walkthrough demonstrates how you can duplicate a Web service that you previously defined and want to use as a substitute. This application was implemented in Walkthrough: Designing a Web Service.

Prerequisites

Complete Walkthrough: Designing a Web Service.

To create a copy of an existing Web service

  1. Open Catalog.sln.

  2. View the application diagram.

  3. Right-click the Catalog application, and click Copy.

  4. Paste the copied application on the application diagram.

  5. Name the pasted version CatalogFacade.

    CatalogFacade includes the same CatalogWebService and GetLegacyInfo endpoints that appear on Catalog. As a result, CatalogFacade is compatible with the all same applications that are compatible with Catalog. All connections from Catalog to other applications, like CatalogDB, are maintained. However, unlike Catalog, CatalogFacade does not appear implemented.

    Note

    Visual Studio does not copy certain settings between applications. As a result, while the database connection appears maintained visually, this connection will not work at run time because Visual Studio does not copy some elements like the password. To enable this connection, you must enter the connection information between CatalogFacade and CatalogDB.

You can thus use the CatalogFacade application as a wrapper Web service for a legacy catalog that is implemented in a legacy application that is not modeled by the Distributed System Designers. You can also represent legacy applications like this on the application diagram by using the Generic application type. For example, such an application might be a ledger system running on an AS/400 machine.

You will now model a legacy application by using the Generic application type.

To model a legacy application

  1. From the Toolbox, drag a GenericApplication application to the diagram and name it LegacyCatalog.

  2. From the Toolbox, drag a .NETWebServiceEndpoint endpoint to CatalogFacade and name it LegacyInterface.

  3. While pressing and holding down the ALT key, drag the LegacyInterface endpoint to LegacyCatalog to connect them.

    A new consumer endpoint appears on LegacyCatalog. LegacyCatalog is an application placeholder for the old catalog. Visual Studio will not generate code for LegacyCatalog. However, its presence on the diagram documents the existence of the legacy application and its connection to the CatalogFacade Web service that wraps its functionality. The next procedure demonstrates how CatalogFacade and Catalog provide the same contract.

To design a catalog system

  1. While pressing the SHIFT key, click Catalog and CatalogDB.

  2. From the Diagram menu, choose Design Application System.

  3. The Design Application System dialog box appears.

  4. Under System name, type NewCatalogSystem.

    System Designer opens with the selected applications included in the new system. Adjust the location of the applications, as needed.

  5. Right-click the CatalogWebService endpoint, and choose Add Proxy Endpoint.

    This action creates a communication pathway into this system.

  6. View the application diagram.

  7. Right-click SalesWebClient, and click Design Application System.

  8. Name the system CatalogSystem.

  9. From the System View window, drag NewCatalogSystem into CatalogSystem.

    Notice that NewCatalogSystem exposes an endpoint so that you can connect the system. This endpoint is the proxy endpoint that you created earlier. It provides connectivity to CatalogWebService on Catalog.

  10. Connect the CatalogWebService proxy endpoint on NewCatalogSystem to the consumer endpoint on SalesWebClient.

  11. View the application diagram.

  12. Create a new system that contains CatalogFacade and LegacyCatalog and name it LegacyCatalogSystem.

  13. Create a proxy endpoint for CatalogWebService in LegacyCatalogSystem.

  14. View the CatalogSystem system.

  15. Delete the NewCatalogSystem system from CatalogSystem.

  16. From the System View window, drag the LegacyCatalogSystem system into the CatalogSystem system.

  17. Connect the CatalogWebService endpoint on the LegacyCatalogSystem system to the consumer endpoint on SalesWebClient.

    The NewCatalogSystem and LegacyCatalogSystem systems each contain the CatalogWebService endpoint, which you exposed as a proxy endpoint. Therefore, you can substitute either system for each other in CatalogSystem.

You will now create a reusable prototype of an application that contains the CatalogWebService and uses Visual C# as the default language. You can add this prototype to the Toolbox.

To create a reusable prototype

  1. View the application diagram.

  2. From the Toolbox, drag an ASP.NETWebService to the diagram.

  3. Copy the CatalogWebService endpoint on Catalog and paste it on the new ASP.NET Web service application.

  4. Change the Language property for the new application to Visual C#.

  5. From the Diagram menu, choose Add to Toolbox.

    The Add to Toolbox dialog box appears.

  6. In the Name box, type CatalogWebServiceApp, and click OK.

    The Save File dialog box appears. Visual Studio saves the file as an .adprototype file, which is application prototype file used in Application Designer.

  7. Click Save.

  8. Open the Toolbox and drag the CatalogWebServiceApp to the diagram.

You have created a reusable and customized version of the ASP.NET Web service application that also includes the CatalogWebService endpoint. This prototype will appear in the Toolbox whenever you create a new distributed systems solution.

You can share this prototype with other Distributed System Designer users by exporting it to a shared location. For more information, see the following topics:

Next Steps

Walkthrough: Representing Indirect Web Service Connections

See Also

Other Resources

Designing Web Services Walkthroughs