<endpointDiscovery>

指定终结点的各种发现设置,例如终结点的可发现性、范围以及对终结点元数据的任何自定义扩展。

架构层次结构

<system.serviceModel>
  <behaviors>
    <endpointBehaviors>
      <endpointBehaviors> 的 <behavior>
        <endpointDiscovery>

语法

<behaviors>  <endpointBehaviors>    <behavior name="String">      <endpointDiscovery enable="Boolean">        <scopes>          <add scope="URI"/>        </scopes>        <extensions>        </extensions>      </endpointDiscovery>    </behavior>  </endpointBehaviors></behaviors>

属性和元素

以下几节描述了特性、子元素和父元素。

属性

特性 说明

enabled

一个布尔值,指定是否对此终结点启用可发现性。默认值为 false

子元素

元素 说明

<scopes>

终结点的范围 URI 集合。一个终结点可以与多个范围 URI 关联。

<extensions>

一个 XML 元素集合,用于指定要对终结点发布的自定义元数据。

父元素

元素 说明

<endpointBehaviors> 的 <behavior>

指定行为元素。

备注

如果将此配置元素添加到终结点的行为配置,并将 enabled 特性设置为 true,此配置元素将启用该终结点的可发现性。此外,还可以使用 <scopes><extensions> 子元素指定应随可检测到的标准元数据(EPR、ContractTypeName、BindingName、Scope 和 ListenURI)一起发布的自定义元数据。

此配置元素依赖于提供发现服务级别控制的 <serviceDiscovery> 元素。这意味着,如果配置中没有 <serviceDiscovery>,则会忽略此元素的设置。

示例

下面的配置示例指定要对终结点发布的筛选范围和扩展元数据。

<services>
  <service name="CalculatorService"
           behaviorConfiguration="CalculatorServiceBehavior">
     <endpoint binding="basicHttpBinding"
              address="calculator"
              contract="ICalculatorService"
              behaviorConfiguration="calculatorEndpointBehavior" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="CalculatorServiceBehavior">
      <serviceDiscovery />
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="calculatorEndpointBehavior">
      <endpointDiscovery enable="true">
        <scopes>
          <add scope="http://contoso/test1"/>
          <add scope="http://contoso/test2"/>
        </scopes>
        <extensions>
          <e:Publisher xmlns:e="http://example.org">
            <e:Name>The Example Organization</e:Name>
            <e:Address>One Example Way, ExampleTown, EX 12345</e:Address>
            <e:Contact>support@example.org</e:Contact>
          </e:Publisher>
          <AnotherCustomMetadata>Custom Metadata</AnotherCustomMetadata>
        </extensions>
      </endpointDiscovery>
    </behavior>
  </endpointBehaviors>
</behaviors>

另请参见

参考

EndpointDiscoveryBehavior