Reputation: 1921
I spent hours trying to do some customizations in the wsdl generation, without results. I got stuck mainly because I could not find a clear sample for what I want to do (I may have missed something).
Let's got to the point : I want to customize the generated WSDL. The most relevant articles I found are about adding attributes to existing Services to add behavior, like this article.
What I want to do is being able to analyze the OperationContract and generate and additionnal xsd if required.
My questions are :
I don't want to change the way the metadata are consumed by svcutil.exe, just add some ComplexType 'on-the-fly' in the generated wsdl.
Thanks for your suggestions !
Upvotes: 4
Views: 4615
Reputation: 364389
What you need is implementing IWsdlExportExtension.ExportContract
but the documentation clearly states:
The ExportContract method is called when the metadata export system is exporting the contract. Only contract and operation behaviors implementing IWsdlExportExtension get the ExportContract call. All behaviors implementing IWsdlExportExtension get the ExportEndpoint call.
For me it means that this method is called only when implemented by contract or operation behavior which is usually defined by custom attribute but you should be also able to assign these behaviors in custom initialization. Here is the example of WSDL extension for endpoint configured from configuration file (configuration offers only behaviors for whole service and endpoints). I believe (but didn't test it) that you can do similar extension which will consist of:
IWsdlExportExtension
and ExportContract
IEndpointBehavior
and ApplyDispatchBehavior
. In ApplyDispatchBehavior
you will use serviceEndpoint.Contract.Behaviors
to add contract behavior or serviceEndpoint.Contract.Operations[x].Behaviors
to add operation behavior.BehaviorExtensionElement
for defining your new endpoint behavior from configuration file.Upvotes: 5