I feel like an utter amateur for falling down on this one but I am providing my story here in case anyone else out there is pulling their hair out for the same reasons.
I was keen to modify the exported wsdl on a WCF service and checked out the many articles out there in the ether to fast-track my efforts. I managed to build a simple HelloWorld service (with client console) and added in the plumbing to implement both IWsdlExportExtension and (in my case), IEndPointBehaviour.
After I felt I had everything in place and (seemingly) configured correctly I tested the service by browsing to it and visually checking the wsdl – no, my modified wsdl wasn’t showing. No errors, just no change in the service description.
I put traces in each of the IWsdlExportExtension and IEndPointBehaviour methods and when I’d hit the service, nothing was coming out in the trace – again, no errors, no output and no change in the wsdl. Frustration Plus.
I thought I’d change tack and get my worker class to implement IServiceExtension instead (just to see some kind of change in behaviour). I modified the configuration appropriately and this time saw that each of my IServiceExtension methods were getting hit…something was happening!
After the umpteenth magnifying-glass-close scrutiny of my service web.config (and after combing over an excellent blog by Carlos Figueira) I noticed a discrepancy – the “name” attribute of my “service” node included the service namespace but the name was slightly off – “HelloWorld” instead of “HelloWorldService” in this case. No match on name, no pointing to the behaviour I had configured!!! I made the change and voila – everything worked – methods getting hit, wsdl getting modified and emitted as expected.
I’ve included my web.config snippet below.
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name=“simpleBehavior“ type=“Mexia.Framework.TestService.SimpleEndPointBehaviour, Mexia.Framework.TestService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null“ />
</behaviorExtensions>
</extensions>
<behaviors>
<endpointBehaviors>
<behavior name=“simpleServiceBehaviour“>
<simpleBehavior />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled=“true“/>
<serviceDebug includeExceptionDetailInFaults=“true“/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name=“Mexia.Framework.TestService.HelloWorldService“>
<endpoint address=“” binding=“basicHttpBinding“ contract=“Mexia.Framework.TestService.IHelloWorldService“ behaviorConfiguration=“simpleServiceBehaviour“ />
<endpoint address=“mex“ binding=“mexHttpBinding“ contract=“IMetadataExchange“ />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled=“true“ />
</system.serviceModel>
Also for some excellent references on WCF extensibility check out some of Carlos’ blogs:
http://blogs.msdn.com/b/carlosfigueira/archive/2011/10/06/wcf-extensibility-wsdl-export-extension.aspx
http://blogs.msdn.com/b/carlosfigueira/archive/2011/04/05/wcf-extensibility-iendpointbehavior.aspx
Hope this helps!
Matt Warwick







