Add a ServiceMetadataBehavior 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.
To enable HTTP GET metadata retrieval, set the HttpGetEnabled property to true. For more information about the address of HTTP GET metadata, see HttpGetEnabled.
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 ServiceMetadataBehavior is used from an application configuration file. See the Example section for a code example.