Walkthrough: Representing Indirect Web Service Connections
In Visual Studio Team System Architecture Edition, you can use an ASP.NET Web service application as a façade for the business functions in class libraries. The Distributed System Designers do not support designing or representing class libraries directly on the application diagram. However, you can still represent class library behavior through the ASP.NET Web service application.
To represent a class library on an application diagram
Open the application diagram.
Add a new ASP.NETWebService to the diagram and name it MyWebService. Name the .NET Web service endpoint FirstWebService.
This creates the Web service that acts as a façade for the class library.
Right-click MyWebService, and click Implement Application.
Add a new ASP.NETWebApplication to the diagram, name it MyWebApplication, and implement it.
This creates a client Web application that uses the functions in the class library through FirstWebService.
Right-click MyWebApplication and click Settings and Constraints to view the Settings and Constraints Editor.
Expand the Application Settings, Directory, and Configuration nodes.
Right-click the NetSectionGroup node, point to Add Resource, and click SettingsSection.
After you add this resource, a Web.config file appears in Solution Explorer.
In Solution Explorer, right-click the Solution node, and click New Project.
The Add New Project dialog box appears.
Under Project types, expand the Visual Basic or Visual C# node, and click Windows. Under Templates, click Class Library, and click OK.
A class library project appears in Solution Explorer.
Right-click the class library project node, and click Add Web Reference.
The Add Web Reference dialog box appears.
Click Web services in this solution.
Under Web Services in this Solution, click FirstWebService, and click Add Reference.
This adds a Web reference for FirstWebService in the class library.
While the class library project remains selected and click Build <class library name> on the Build menu.
This builds the class library and adds an App.config file to the class library project.
In Solution Explorer, right-click the MyWebApplication project node, and click Add Reference.
The Add Reference dialog box appears.
Click the Projects tab, click the class library project, and click OK.
This adds a reference for the class library to MyWebApplication.
Open the Web.config file in the MyWebApplication project.
Open the App.config file in the class library project.
Copy the <configSections> section from App.config and paste it into Web.config. This section looks similar to the following:
<configSections> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <section name="ClassLibrary1.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </sectionGroup> </configSections>
Copy the <applicationSettings> section from App.config and paste it into Web.config below <configSections>. This section looks similar to the following:
<applicationSettings> <ClassLibrary1.Settings> <setting name="ClassLibrary1_localhost_WebService1" serializeAs="String"> <value>https://localhost:1665/MyWebService/FirstWebService.asmx</value> </setting> </ClassLibrary1.Settings> </applicationSettings>
The beginning of Web.config should now look like this:
<configuration xmlns="https://schemas.microsoft.com/.NetConfiguration/v2.0"> <configSections> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <section name="ClassLibrary1.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </sectionGroup> </configSections> <appSettings> </appSettings> <applicationSettings> <ClassLibrary1.Settings> <setting name="ClassLibrary1_localhost_WebService1" serializeAs="String"> <value>https://localhost:1665/MyWebService/FirstWebService.asmx</value> </setting> </ClassLibrary1.Settings> </applicationSettings> <connectionStrings/> <system.web>
Build the solution and then view the application diagram.
A consumer endpoint appears on MyWebApplication. This consumer endpoint connects to the FirstWebService endpoint on MyWebService. This endpoint represents the connection from the Web reference in the class library project to the Web service.
See Also
Other Resources
Designing Web Services Walkthroughs
Referencing Class Libraries from Applications on Application Diagrams