문제

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 :

  • How can you add or intercept existing WSDL generation without adding attributes ?
  • How do I configure this component in the config file ?

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 !

도움이 되었습니까?

해결책

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:

  • Operation or Contract behavior implement IWsdlExportExtension and ExportContract
  • Endpoint behavior which will implement 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.
  • You will create similar BehaviorExtensionElement for defining your new endpoint behavior from configuration file.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top