How to: Expose a Metadata Endpoint
Updated: January 6, 2015
A Microsoft Azure Service Bus metadata endpoint is a URI that exposes additional information about a service or client application. For example, the Svcutil.exe tool uses the exposed metadata from a service to build a contract so that a developer can access that service. Without the metadata, the developer would have to gain access to the contract in some other way, such as asking the creator for a copy of it directly via e-mail. Note that you can still implement an interface without metadata: metadata enables you to easily obtain the contract if you do not already have it. Also note that exposing a metadata endpoint differs from publishing your interface to the ATOM feed: the metadata endpoint contains additional information about the contract, whereas publishing on the ATOM feed just lists the service URI in a publicly-accessed database.
The following is a simplified procedure for exposing metadata on an application that uses Service Bus. For a complete discussion of metadata, see Metadata Architecture Overview in the Windows Communication Foundation (WCF) documentation.
In the App.config file for the host application, add the metadata endpoint definition to the service configuration information.
<services> <service name="Service.EchoService"> <endpoint name="RelayEndpoint" ... /> <endpoint name="MexEndpoint" contract="IMetadataExchange" binding="netTcpRelayBinding" bindingConfiguration="default" address="mex" /> </service> </services>
To add metadata publishing to the service, modify the application configuration information to include an additional
<system.serviceModel> ... <behaviors> <endpointBehaviors> ... <endpointBehaviors> <serviceBehaviors><behavior name="serviceMetadata"><serviceMetadata /></behavior></serviceBehaviors> </behaviors> </system.serviceModel>
Add the metadata behavior to the service by specifying the
behaviorConfigurationproperty in the service definition.
<services> <service name="Service.EchoService" behaviorConfiguration="serviceMetadata"> ... </service> </services>
Warning If the metadata endpoint is specified with a different end-to-end security mode than the service endpoint, and uses a relative address while sharing the same base address with the service endpoint, an exception of type System.ArgumentException is thrown when you open the service host. The following error message accompanies the exception: Incompatible channel listener settings. To resolve this issue, perform one of the following workarounds:
Specify the address of the metadata endpoint as a fully-qualified address.
If you want to use a relative address for the metadata endpoint that shares a base address with the service endpoint, specify the same end-to-end security mode for both the metadata and service endpoints.
Use a relative address for the metadata endpoint with a base address that differs from the base address of the service endpoint.
- Specify the address of the metadata endpoint as a fully-qualified address.