Export (0) Print
Expand All

Walkthrough: Creating Substitutable Web Services 

This walkthrough demonstrates how to construct a duplicate of a Web service you have created from a specification standpoint, using copy and paste. In this case, you will create a copy of the Catalog application and associated endpoints. This application was implemented in Walkthrough: Designing a Web Service.

To create a copy of an existing Web service

  1. Open Catalog.sln.

  2. View Application Designer.

  3. Select the Catalog application, right-click and choose Copy.

  4. Paste the copied application onto the application diagram.

  5. Name the copy of Catalog "CatalogFacade".

    While the Catalog application was implemented, the copy of Catalog is not. CatalogFacade also includes the CatalogWebService and GetLegacyInfo endpoints that are on Catalog. As a result, CatalogFacade is plug compatible with Catalog. All connections from Catalog to other applications, like CatalogDB, are maintained.

    NoteNote

    Secure settings between applications are not copied. As a result, while the database connection is visually maintained, this connection will not work at runtime because necessary elements like the user name and password are not copied for security reasons. To enable this connection, you must enter the connection information between CatalogFacade and CatalogDB.

The CatalogFacade application is a wrapper Web service for a legacy catalog implemented in a legacy application not modeled by the Distributed System Designers. Legacy applications like this can be represented on the application diagram, though, using the Generic application type. Examples of such an application might be a ledger system running on an AS/400 machine. Modeling legacy applications using the generic application is demonstrated in the following procedure.

To model a legacy application

  1. From the Toolbox, drag a GenericApplication application to the diagram.

  2. Name the application "LegacyCatalog".

  3. From the Toolbox drag a new WebService endpoint to CatalogFacade and name the endpoint "LegacyInterface".

  4. Select the LegacyInterface provider endpoint, press ALT, and drag to connect it to LegacyCatalog.

    A new consumer endpoint appears on LegacyCatalog. LegacyCatalog is an application placeholder for the old catalog. No code will be generated for it, but 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. Press SHIFT while selecting the Catalog and CatalogDB applications.

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

  3. The Design Application System dialog box appears.

  4. Under System name:, enter "NewCatalog".

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

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

    This action creates a communication pathway into this system.

  6. View the application diagram.

  7. Select the Sales Web Client application, right-click, and choose Design Application System.

  8. Name the system, "CatalogSystem".

  9. Using the System View window (displayed at left), drag the NewCatalog system onto the CatalogSystem system.

  10. Notice that NewCatalog provides an endpoint for connecting to the system. This endpoint is the proxy endpoint you created earlier and it provides connectivity to the Catalog Web service.

  11. Connect the Catalog1 endpoint on New Catalog to the consumer endpoint on SalesWebClient.

  12. View the application diagram.

  13. Create a new system containing CatalogFacade and LegacyCatalog. Name this system "LegacyCatalog".

  14. Create a proxy endpoint for CatalogWebService in the LegacyCatalog system.

  15. View the CatalogSystem system.

  16. Select the NewCatalog system and press DELETE. This removes NewCatalog from CatalogSystem.

  17. Using System View, drag LegacyCatalog into CatalogSystem.

  18. Connect the Catalog endpoint on LegacyCatalog to the consumer endpoint on SalesWebClient.

    Because the NewCatalog and LegacyCatalog systems each contained the Catalog Web service, which they exposed as a proxy endpoint into the system, either system is substitutable for the other in the CatalogSystem system.

The final step in this walkthrough is to create a prototype of an application that contains the CatalogWebService and uses C# as the default language. You can place this prototype on the Toolbox.

To create a reusable prototype

  1. View Application Designer.

  2. From the Toolbox, drag an ASP.NETWebService application to the diagram. It will be named WebApplication1, by default.

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

  4. Select WebApplication1 and change the Language property to Visual C#.

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

    The Add to Toolbox dialog box appears.

  6. Under Name, enter CatalogWebServiceApp and click OK.

    The Save File dialog box appears. The file is saved as an .adprototype, meaning that it is an application prototype used in Application Designer.

  7. Click Save.

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

By creating this reusable prototype you have created a customized version of the default Web service prototype that includes your Catalog Web service. This prototype will display whenever you create a new Distributed System solution. It is a function of the designers and not the solution that was open when you created it.

Other Distributed System Designer users can share this prototype by placing a copy of the .adprototype file in the default prototype folder, which is typically located at <root>\Program Files\Microsoft Visual Studio 8\Common7\Tools\DesignerPrototypes\Prototypes. For more information about creating reusable prototypes in Application Designer, see How to: Create Application Prototypes from Configured Applications and Endpoints.

Community Additions

ADD
Show:
© 2014 Microsoft