In the previous example we added the ServiceMetaData behaviour to our EchoService WCF service example. By setting httpGetEnabled to true, the service publishes WSDL service metadata for clients to configure endpoints. A more sophisticated way of publishing metadata over a variety of transport protocols is by implementing a MEX endpoint with the IMetaDataExchange contract. To prevent WSDL metadata via http set httpGetEnabled to false. Now configure a MEX endpoint.
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="BehaviourMetaData"> <serviceMetadata httpGetEnabled="false" httpGetUrl="http://localhost:8080/EchoService/metadata" /> </behavior> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="BehaviourMetaData" name="WcfServiceLibrary.Echo.EchoService"> <endpoint address="net.tcp://localhost:8081/EchoService/mextcp" binding="mexTcpBinding" contract="IMetadataExchange" /> <endpoint address="http://localhost:8080/EchoService" binding="basicHttpBinding" contract="WcfServiceLibrary.Echo.IEchoService" /> </service> </services> </system.serviceModel> </configuration>
Running the ServiceModel Metadata Utility Tool SvcUtil to test the MEX endpoint shows it works as expected.
