I am using VSTS 2008 + C# + .NET 3.0. I am using a self-hosted WCF service. When executing the following statement, there is the following \"binding not found\" error. I hav
I've asked a question in a comment for Marc_s answer
Is it possible to have IMetadataExchange for both http and https as separate endpoints?
marc_s answered
you should be able to define a second base address, for http:// and use that for the http mex endpoint.
So solution is to declare multiple endpoints with the SAME address="mex" and different bindings like the following
Recently I found that it's easier to have one configuration switch that can be used to enable MEX on test and disable on Live.
From http://msdn.microsoft.com/en-us/library/aa395224.aspx
It's possible to use the ServiceHostFactory class to create a custom derived from ServiceHost in the Internet Information Services (IIS custom ServiceHost that adds the ServiceMetadataBehavior, (which enables metadata publishing), even if this behavior is not explicitly added in the service’s configuration file.
Write the imperative code that enables metadata publishing once and then reuse that code across several different services. This is accomplished by creating a new class that derives from ServiceHost and overrides the ApplyConfiguration() method to imperatively add the metadata publishing behavior.
Example code from Custom Service Host MSDN article
//Add a metadata endpoint at each base address
//using the "/mex" addressing convention
foreach (Uri baseAddress in this.BaseAddresses)
{
if (baseAddress.Scheme == Uri.UriSchemeHttp)
{
mexBehavior.HttpGetEnabled = true;
this.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName,
MetadataExchangeBindings.CreateMexHttpBinding(),
"mex");
}
else if (baseAddress.Scheme == Uri.UriSchemeHttps)
{
mexBehavior.HttpsGetEnabled = true;
this.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName,
MetadataExchangeBindings.CreateMexHttpsBinding(),
"mex");
}
else if (baseAddress.Scheme == Uri.UriSchemeNetPipe)
{
this.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName,
MetadataExchangeBindings.CreateMexNamedPipeBinding(),
"mex");
}
else if (baseAddress.Scheme == Uri.UriSchemeNetTcp)
{
this.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName,
MetadataExchangeBindings.CreateMexTcpBinding(),
"mex");
}
}