Export (0) Print
Expand All

WCF Configuration Tools

.NET Framework 4

Applies to: Windows Communication Foundation

Published: June 2011

Author: Robert Dizon

This topic contains the following sections.

Windows Communication Foundation (WCF) 4.0 is significantly easier to use than earlier versions of the product. WCF 4.0 includes simplified configuration, service discovery, a routing service, an improved web HTTP API which uses plain XML for messaging that make it easier to implement Representational State Transfer (REST), and a workflow service. These new features, and the fact that it is fairly straightforward to migrate an existing WCF solution to the current version, will encourage many enterprises to adopt WCF 4.0.

The earlier versions of WCF (3.x) offered a unified programming model that made it easier to write services for a variety of scenarios. However, this versatility came at the cost of complex configurations. Developers had to understand and configure the communication settings before they could make the service operational. Post production, configuration often became the responsibility of the IT Operations team, who were not trained to deal with its intricacies. WCF 4.0 addresses this complexity with a default configuration. If you do not provide any WCF configuration information for a particular service, the WCF runtime automatically configures it with standard endpoints, and default settings for bindings and behavior. The default behavior is useful as a proof-of-concept that demonstrates if a particular integration scenario meets its requirements. Later, the default configuration can be fine-tuned in development and for production.

This article shows you how to use a variety of WCF tools to help you fine-tune enterprise-level WCF services through configuration. In addition, it provides guidelines for designing an integrated set of services that can fulfill a variety of business objectives. The successful implementation of these web services, which typically handle large volumes of traffic, requires a carefully structured design, thorough testing, and a planned approach to configuration.

Here are some best practices to adopt when you begin to design your service.

  • Give careful thought to the size of the web service's inbound and outbound messages.

  • Have a realistic estimate, which should be confirmed by accurate analysis, of the frequency of messages, both for peak and off-peak times.

  • Understand your own assumptions about how a high-traffic service will perform, and about its scalability.

  • Identify the test strategies that you will employ during development, such as unit testing, along with the data sets that you will use.

  • Identify the configuration parameters for all of the integration points. Examples of integration points are the presentation layer, the application servers, the WCF hosts, the enterprise resource planning (ERP) application interfaces, and the database.

You can download the example WCF hosted service, which is packaged as an IIS project from this location: WCFServiceApplicationA.zip.

WCF comes with many useful tools that can help you to deploy and manage WCF service applications. You can run these tools from the Microsoft® Visual Studio® 2010 development system command prompt. The following figure illustrates one way to access the command prompt from within Visual Studio.

Referenced Screen

This article discusses how to use the following tools.

  1. Service Configuration Editor (SvcConfigEditor.exe) - Use this WCF tool to create and modify a WCF service's configuration settings. This article demonstrates how to use the editor to enable WCF diagnostics.

  2. Performance Monitor (PerfMon.exe) - Use this Windows tool to monitor the performance of the Windows environment. The performance monitor is configured with the configuration editor.

  3. Service Trace Viewer Tool (SvcTraceViewer.exe) - Use this WCF tool to view the WCF service's execution traces.

  4. WCF Test Client (WcfTestClient.exe) - Use this tool to test a WCF hosted service. It allows you to call a service operation, and view the service's response. The tool includes a graphical user interface (GUI).

For a complete list of the WCF Tools, visit the Windows Communication Foundation Tools site on MSDN at http://msdn.microsoft.com/en-us/library/ms732015.aspx

Service Configuration Editor (SvcConfigEditor.exe)

The Service Configuration Editor (SvcConfigEditor.exe) is a GUI-based editor that allows you to configure WCF bindings, behaviors, and diagnostic settings for WCF services. To launch the tool, open a Visual Studio command prompt and type svcconfigeditor.exe. Click on File, click Open, and then click on the type of file you want to open. Here are the types of files that you can create and edit.

  • Config File - This is a WCF hosted service IIS web configuration file. It can be either a web.config file or app.config file.

  • Executable - This is a standard windows executable application (exe).

  • COM+ Service - This is a COM+ service that is configured for WCF. This option automatically detects and displays all of the WCF services that are hosted on your system.

  • Web Hosted Service - This option opens all of the sites in your IIS virtual directories.

If you have deployed the WCFServiceApplicationA sample application to IIS, use the configuration editor to navigate to the service's location, and click web.config. Click Diagnostics. Click Toggle Performance Counters until you see All. The following figure illustrates what you should see.

Referenced Screen

The Performance Counter setting has three options. They are:

  • All: All counters in all categories are enabled. These categories include ServiceModelService, ServiceModelEndpoint, and ServiceModelOperations.

  • ServiceOnly: Only counters in the ServiceModelService category are enabled.

  • Off: All counters in all categories are disabled. This is the default value.

For more information, see Configuration Editor Tool on MSDN at http://msdn.microsoft.com/en-us/library/ms732009.aspx

After you use the editor to enable the performance counter categories, use the performance monitor to view the data that is captured. To launch the performance monitor from the desktop, click Start, and type perfmon.exe in the Search box. To begin data collection, click the Start the Data Collector Set icon on the toolbar. All the data that is collected is in a log file, under Output. The following illustration shows the physical location of the log file for the performance counter data.

Referenced Screen

To view the graphical monitor, click Performance Monitor in the left pane. To add counters, click the green plus sign in the tool bar that is above the graphical monitor. The following figure illustrates the Add Counters dialog box.

Referenced Screen

After you add the performance counters (for example, Application Catch Hits %) the data is displayed in the monitor in real time. The following figure illustrates an example.

Referenced Screen

The performance monitor also can be used for performance and scalability tests.

Service Trace Viewer Tool (SvcTraceViewer.exe)

The Service Trace Viewer Tool keeps a log that enables you to analyze WCF diagnostic traces. You can merge, view, and filter trace messages in the log in order to verify, diagnose, and repair WCF issues. To configure tracing, you must modify the application's web.config file for IIS hosted or app.config if the service is self-hosted. The following code is an example of how to do this. (The relevant XML code is in bold.)

<system.diagnostics>
    <trace autoflush="true" />
    <sources>
            <source name="System.ServiceModel" 
                    switchValue="Information, ActivityTracing"
                    propagateActivity="true">
            <listeners>
               <add name="sdt" 
                   type="System.Diagnostics.XmlWriterTraceListener" 
                   initializeData= "SdrConfigExample.svclog" />
            </listeners>
         </source>
    </sources>
</system.diagnostics>

The following figure illustrates the web.config file for the sample WCFServiceApplicationA application that accompanies this article.

Referenced Screen

To verify that tracing is enabled, first browser to the web site and make sure that the WCF service is operational. Next, use the wcftestclient.exe tool to invoke the WCF web service. In the left pane of the tool, click the GetData web service. In the right pane, under Request, change the entry in the Value column to 1. Click the Invoke button. The response should be WS #1: 1. The following figure illustrates what you should see.

Referenced Screen

There is a service trace log file named SdrConfigExample.svclog in the root location of the WCF service. Launch SvcTraceViewer.exe and open the log file. It will show all of the trace activities for the WCF web service. The SvcTraceViewer tool enables you to select between a formatted view of the log, and an XML view of the log. See the above figure for the location of the two tabs that allow you to toggle between them. The following figure illustrates the XML view of the trace log file.

Referenced Screen

The XML view displays the actual XML messages.

For more information, see Service Trace Viewer Tool on MSDN at http://msdn.microsoft.com/en-us/library/ms732023.aspx

Previous article: Message Level Security

Continue on to the next article: Service Reusability

Show:
© 2014 Microsoft