WSDL in Mono

Mono can host WCF services and expose the WSDL. To get around the XmlSchema error: Named item http://your/contract/here was already contained in the schema object table you need to set MONO_STRICT_MS_COMPLIANT to ‘yes’. Here is how I managed to do that.

// set MONO_STRICT_MS_COMPLIANT
if (Environment.GetEnvironmentVariable("MONO_STRICT_MS_COMPLIANT") != "yes") 
{ 
    Environment.SetEnvironmentVariable("MONO_STRICT_MS_COMPLIANT", "yes"); 
}

var host = new ServiceHost(typeof(Service), new Uri("http://localhost:999/Service.svc"));
host.AddServiceEndpoint(typeof(IService), new BasicHttpBinding(), string.Empty);
// add the MetadataBehavior to enable HttpGet
host.Description.Behaviors.Remove<ServiceMetadataBehavior>();
host.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpGetEnabled = true });
host.Open();

Original post in Chinese is here http://www.cnblogs.com/wdysunflower/archive/2011/07/22/2113112.html

Unknown's avatar

About erictummers

Working in a DevOps team is the best thing that happened to me. I like challenges and sharing the solutions with others. On my blog I’ll mostly post about my work, but expect an occasional home project, productivity tip and tooling review.
This entry was posted in Development and tagged , , , , , , . Bookmark the permalink.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.