Mar 29, 2010

How to Expose WCF Service Meta Data Exchange EndPoint

In a previous post, I use Factory in .svc to host custom WCF service in SharePoint 2010 without any configuration in web.config. This approach is simple, but you might get the followings:

Metadata publishing for this service is currently disabled.

The reason is, the service meta data is not exposed, and for the same reason, when you try to use Visual Studio to add "service reference", you won't be able to find the service.

The solution is, obviously, to define MetaData Exchange endpoint. But that can not be done with Factory, we have to use comfiguration approach.

In the service subfolder under ISAPI mapped folder, add a web.config with configuration like this:

This will work fine only for anonymous enabled IIS site, you will otherwise get the error:

Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

The workaround is to define a secure binding configuration for both endpoints: