Customizing auto-generated service metadata
WCF provides metadata endpoints that can help to automatically publish WSDL metadata for the hosted service. And this auto-generated WSDL metadata can be easily customized through the IWsdlExportExtension
interface so as to fit some special requirements in our service development.
How to do it...
In this recipe, we will use a web-hosted WCF service (with a metadata endpoint enabled) as an example to demonstrate how to customize the auto-generated WSDL metadata.
Create a class that implements both the
IWsdlExportExtension
andIEndpointBehavior
interfaces.The first thing to do is create a custom type that implements the
IWsdlExportExtension
andIEndpointBehavior
interfaces. TheIWsdlExportExtension
interface provides extension points for injecting custom code logic in the WSDL metadata generation, while theIEndpointBehavior
interface will make the custom extension type be able to inject into the target service endpoint's behavior collection. In our...