Aracılığıyla paylaş


<system.serviceModel>

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

Syntax

<system.serviceModel>
    <behaviors>
    </behaviors>
    <bindings>
    </bindings>
    <client>
    </client>
    <comContracts>
    </comContracts>
    <commonBehaviors>
    </commonBehaviors>
    <diagnostics>
    </diagnostics>
    <extensions>
    </extensions>
    <serviceHostingEnvironment>
    </serviceHostingEnvironment>
    <services>
    </services>
</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.

<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.

<client>

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

<comContracts>

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

<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.

<extensions> section

This element contains a collection of extensions, which enable the user to create user-defined bindings, behaviors, and other aspects of extensions.

<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.

<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.

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


© 2007 Microsoft Corporation. All rights reserved.
Last Published: 2010-01-05