How to enable Metadata Exchange in WCF?How to enable Metadata Exchange automatically in WCF?

How to enable Metadata Exchange in WCF?How to enable Metadata Exchange automatically in WCF? Here First we should know that WCF can provide the metadata of you service automatically as well as programmatically . Here I am explaining the way How to enable metadata exchange automatically.you need to enable it by adding an explicit service behavior. we can do this over HTTP GET method.To enable ie you hato do the below given changes in config file.

<System.ServiceModel>
<Services>
<Service name ="MyService" behaviorConfiguration="MEXGET">
<host>
<BaseAddresses>
<add beseAddress="HTTP://localhost:8002/" />
</BaseAddresses>
</host>
...
</Service>
<Service name ="MyNextService" behaviorConfiguration="MEXGET">
<host>
<BaseAddresses>
<add beseAddress="HTTP://localhost:8002/" />
</BaseAddresses>
</host>
...
</Service>
</Services>
<Behaviors>
<ServiceBehaviors>
<behavior Name ="MEXGET">
<ServiceMetadata HttpGetEnabled="true" />
</behavior>
</ServiceBehaviors>
</Behaviors>
</System.ServiceModel>



By default, the address the client need to use for HTTP-GET is the registered HTTP base Address of the service.If the host is not configured with the baseaddress, loading the service will throw the exception.You can also specify a different address at which to publish the metadata by setting the httpGetUrl property of the serviceMetaData tag:

<behavior name="MEXGET">
<ServiceMetadata httpGetEnabled = "true" HttpGetUrl = "MyMEXAddress" />
</behavior>

Posted in

Leave a Reply

Your email address will not be published. Required fields are marked *