Controls the publication of service metadata and associated information.
Assembly: System.ServiceModel (in System.ServiceModel.dll)
Add a object to the ServiceDescription.Behaviors collection (or the <serviceMetadata> element in an application configuration file) to enable or disable the publication of service metadata. However, adding the behavior to a service is not sufficient to enable metadata publication:
To enable WS-Transfer GET metadata retrieval, you must also add an endpoint to your service in which the contract is IMetadataExchange. For an example, see How To: Publish Metadata for a Service Using Code. The IMetadataExchange endpoint can be configured as can any other endpoint.
The address of the IMetadataExchange endpoint follows the normal rules regarding the combination of base addresses and endpoint addresses. For more information, see Publishing Metadata.
To enable the publication of metadata using a configuration file, add the <serviceMetadata> element to the <serviceBehaviors> element and associate the element with the <service> element for which you want to publish metadata. For an example, see How to: Publish Metadata for a Service Using a Configuration File. The class has the following members:
The HttpGetEnabled property specifies whether metadata is returned for HTTP/GET requests.
The HttpGetUrl property (in conjunction with the base addresses) specifies the HTTP/GET address.
The HttpsGetEnabled property specifies whether metadata is returned for an HTTPS/GET request.
The HttpsGetUrl property (in conjunction with the base addresses) specifies the HTTPS/GET address.
The MetadataExporter property returns the underlying exporter.
Typically the is used from an application configuration file. See the Example section for a code example.
The following code example demonstrates the use of in a configuration file to enable metadata support for HTTP GET and WS-Transfer GET requests.
<configuration> <system.serviceModel> <services> <service name="Microsoft.WCF.Documentation.SampleService" behaviorConfiguration="metadataSupport" > <host> <baseAddresses> <add baseAddress="http://localhost:8080/SampleService" /> </baseAddresses> </host> <endpoint address="" binding="wsHttpBinding" contract="Microsoft.WCF.Documentation.ISampleService" /> <!-- Adds a WS-MetadataExchange endpoint at --> <!-- "http://localhost:8080/SampleService/mex" --> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> <behaviors> <serviceBehaviors> <behavior name="metadataSupport"> <!-- Enables the IMetadataExchange endpoint in services that --> <!-- use "metadataSupport" in their behaviorConfiguration attribute. --> <!-- In addition, the httpGetEnabled and httpGetUrl attributes publish --> <!-- Service metadata for retrieval by HTTP/GET at the address --> <!-- "http://localhost:8080/SampleService?wsdl" --> <serviceMetadata httpGetEnabled="true" httpGetUrl=""/> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> </configuration>
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.