Share via


<system.serviceModel>

This configuration section contains all the Windows Communication Foundation (WCF) ServiceModel configuration elements.

                                    
                                    <system.serviceModel>
                                
                                    
                                        <behaviors>
                                
                                    
                                        </behaviors>
                                
                                    
                                        <commonBehaviors>
                                
                                    
                                        </commonBehaviors>
                                
                                    
                                        <client>
                                
                                    
                                            
                                    
                                        </client>
                                
                                    
                                        <diagnostics>
                                
                                    
                                        </diagnostics>
                                
                                    
                                        <serviceHostingEnvironment>
                                
                                    
                                        </serviceHostingEnvironment>
                                
                                    
                                        <comContracts>
                                
                                    
                                        </comContracts>
                                
                                    
                                            
                                    
                                        <services>
                                
                                    
                                        </services>
                                
                                    
                                        <bindings>
                                
                                    
                                        </bindings>
                                
                                    
                                    </system.serviceModel>
                                

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

None

Child Elements

Element Description

behaviors

This element defines two child collections named endpointBehaviors and serviceBehaviors. Each collection defines behavior elements consumed by endpoints and services respectively. Each behavior element is identified by its unique name attribute.

client

This element contains a list of endpoints a client uses to connect to a service.

commonBehaviors

This element can only be defined in the machine.config file. It defines two child collections named endpointBehaviors and serviceBehaviors. Each collection defines behavior elements consumed by all WCF endpoints and services on the machine respectively. If a behavior is defined in both <commonBehaviors> and <behaviors> sections, the behavior in the <behaviors> section is given preference.

diagnostics

This element contains settings for the diagnostics features of WCF. The user can enable/disable tracing, performance counters, and the WMI provider, and can add custom message filters.

serviceHostingEnvironment

This element defines what type the service hosting environment instantiates for a particular transport. If this section is empty, the default type is used.

comContracts

This element defines COM contracts enabled for WCF and COM interop.

services

The element contains a collection of services. For each service defined in the assembly, this element contains a service element specifying settings for the service.

bindings

This element holds a collection of standard and custom bindings. Each entry is identified by its unique name. Services use bindings by linking them using the name.

Parent Elements

Element Description

<configuration>

The root element for all configuration elements in a .NET configuration file.

Remarks

WCF does not add elements to the configuration sections of other products.

WCF services are defined in the services section of the configuration file. An assembly can contain any number of services. Each service has its own service configuration section. The section and its content define the service contract, behavior, and endpoints of the particular service.

Only a service's name attribute is required. By default, a service's name describes the underlying CLR type used to implement a service; however, you may change the ConfigurationName property on a ServiceContractAttribute to override the CLR type requirement.

The behaviorConfiguration attribute is optional. It identifies the service behavior used by a service. The behavior specified by this attribute must link to a service behavior defined in the scope of the same configuration file (i.e. the same file or a parent file).

Each service exposes one or more endpoints defined in an endpoint element. Each endpoint has its own address and binding. All bindings used within the configuration file must be defined in the scope of the file.

Bindings are linked to endpoints through the combination of the attributes name and bindingConfiguration. The binding attribute defines in which section the binding is defined. The bindingConfiguration attribute defines which configured binding within the binding section is used. A binding section can define several configured bindings.

Example

This is an example of a WCF configuration file.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <behaviors>
            <…List of Behaviors>
        </behaviors>
        <client>
            <…List of Endpoints>
        </client>
        <diagnostics wmiProviderEnabled="false" performanceCountersEnabled="false" tracingEnabled="false">
        </diagnostics>
        <serviceHostingEnvironment>
            <…List of entries>
        </serviceHostingEnvironment>
        <comContracts>
             <..List of COM+ Contracts>
        </comContracts>        <services>
            <…List of Services>
        </services>
        <bindings>
            <…List of Bindings>
        </bindings>
    </system.serviceModel>
</configuration>

See Also

Reference

ServiceModelSectionGroup

Footer image

Send comments about this topic to Microsoft.
© Microsoft Corporation. All rights reserved.