WCF - Individual WDSL Generation

I spent hours trying to make some settings in wsdl generation, without any results. I was stuck mainly because I could not find a clear sample of what I want to do (maybe I missed something).

Let's say: I want to configure the created WSDL. The most important articles I found relate to adding attributes to existing services to add behavior like this article .

What I want to do is the ability to analyze OperationContract and generate and add xsd if necessary.

My questions:

  • How to add or intercept existing WSDL generation without adding attributes ?
  • How to configure this component in the configuration file?

I don't want to change the way metadata is used with svcutil.exe , just add ComplexType on the fly in the generated wsdl.

Thanks for your suggestions!

+4
source share
1 answer

You need to implement IWsdlExportExtension.ExportContract , but the documentation clearly states:

The ExportContract method is called when the metadata export system exports the contract. Only the contract and the implementation of operations carrying out IWsdlExportExtension receive an ExportContract Call. All kinds of behavior implementation of IWsdlExportExtension get call ExportEndpoint.

For me, this means that this method is only called when it is implemented under a contract or behavior, which is usually defined by a user attribute, but you should also be able to assign these behaviors in user initialization. Here is an example of a WSDL extension for an endpoint configured from a configuration file (the configuration offers only behavior for the entire service and endpoints). I believe (but have not verified) that you can make a similar extension that will consist of:

  • Operation or Behavior Under IWsdlExportExtension and ExportContract
  • endpoint behavior that IEndpointBehavior and ApplyDispatchBehavior will implement. In ApplyDispatchBehavior you will use serviceEndpoint.Contract.Behaviors to add contract behavior or serviceEndpoint.Contract.Operations[x].Behaviors to add operation behavior.
  • You will create a similar BehaviorExtensionElement to define your new endpoint behavior from the configuration file.
+5
source

All Articles