Where did the Metadata Exchange Point (MEX) go in WCF RC1?
Last Wednesday evening I joined a Presentation of a colleague of mine (Gert Jan Timmerman) on WCF. I already had some extensive training on WCF that was provided by Microsoft itself here in the Netherlands, but I attended the session just to see if he had some new insights into this technology. As it appeared he actually did J My Colleague had decided to give the presentation based on the .NET 3.0 RC1 that MS released early Wednesday morning. The RC1 was only available a few hours before the presentation, but since this was an in company presentation he decided it would be fun to work with the latest greatest stuff.
That turned out to be quite a challenge because the RC has undergone the by now famous security push. You know the credo, ship with secure defaults J This is where security will win above usability and that might be frustrating sometimes. (See e.g. my post on the ASP.NET cache object)
Well the same goes here as well. Because we got challenged with the fact that we could not get information from the Metadata Exchange Point(MEX) anymore.
While it was turned off by default in the earliest bits, it was on by default since Beta 1.Well as it turns out Metadata is now off by default. Also HTTP GET is turned off by default.
So for a service to expose metadata, the ServiceMetadataBehavior must be configured on the service by hand. Once you have configured the behavior, you can publish metadata by configuring an endpoint to expose the IMetadataExchange contract. To help you out how to configure the MEX endpoint to be available again I have provided a sample configuration that will expose a MEX endpoint at http://localhost:8000/MyService/mex and also enables WSDL requests over HTTP GET at http://localhost:8000/MyService?wsdl
(b.t.w. have a good look at the additional baseAddresses tag show in the example. This is on feature request heard many times, and yes it is now possible to configure a base address for your services)
<system.serviceModel>
<services>
<service name="MyService" behaviorConfiguration="SomeServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/MyService"/>
</baseAddresses>
</host>
<endpoint address=""
binding="wsHttpBinding"
contract="MyService.ISomeService" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SomeServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>