How to programmatically generate WSDL from WCF service (Integration Testing)

Posted by David Christiansen on Stack Overflow See other posts from Stack Overflow or by David Christiansen
Published on 2010-06-16T10:18:21Z Indexed on 2010/06/16 10:22 UTC
Read the original article Hit count: 241

Filed under:
|
|
|

Hi All,

I am looking to write some integration tests to compare the WSDL generated by WCF services against previous (and published) versions. This is to ensure the service contracts don't differ from time of release.

I would like my tests to be self contained and not rely on any external resources such as hosting on IIS.

I am thinking that I could recreate my IIS hosting environment within the test with something like...

using (ServiceHost host = new ServiceHost(typeof(NSTest.HelloNS), new Uri("http://localhost:8000/Omega")))
{
    host.AddServiceEndpoint(typeof(NSTest.IMy_NS), new BasicHttpBinding(), "Primary");
    ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
    behavior.HttpGetEnabled = true;
    host.Description.Behaviors.Add(behavior);
    host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");
    host.Open();
}

Does anyone else have any better ideas?

© Stack Overflow or respective owner

Related posts about wcf

Related posts about nunit