tags:

views:

1405

answers:

3

Hi Guys,

based on the WSDL spec from W3 there is the possibility to add "wsdl:document" tags to the WSDL output so that people using that webservice have a better explanation/documentation about this webservice.

Does anybody know how to make WCF use these comments/descriptions, or how to write the code in C# that those comments are exported as part of the wsdl?

Thanks, Michael

+1  A: 

WCF won't do it on it's own unfortunately. There are extensibility points for WSDL generation that you can use to accomplish this at least partially: Look up the IWSDLExportExtension interface.

I have a small example on how to implement a simple WSDL export extension up on my website which might help you get started.

tomasr
Thanks - but that's just a first step. What I'd really like is the ability to export any "/// comments...." I made on the ServiceContract, OperationContract and DataContract into the WSDL and XSD. Any ideas?
marc_s
+1  A: 

If you're doing your design / coding in C# classes, adorned with [ServiceContract] and [OperationContract], then I don't know of any way to export documentation you might have on those classes and methods into the WSDL, unfortunately.

I was appalled by that too - I expected any /// comments on my classes and methods to show up in the WSDL - no luck :-(

Our solution now is this: 1) we create a basic "mockup" of our service interface with all operations in C# 2) we compile that into an assembly 3) we extract the metadata (WSDL, XSD) from that assembly and then throw away the C# "prototype" 4) we manually add comments (xs:annotation/xs:documentation) to the WSDL and XSD 5) from now on, the WSDL/XSD are the master - and we generate our interface from those descriptions

Cumbersome and annoying, but it works fairly ok for us.

I sure hope VS2010 / WCF 4.0 will bring us a bit more support in this area !!

Marc

marc_s
This seems like a good approach.
Cheeso
+2  A: 

It seems that the community project WCFExtras on CodePlex provides a work-around the limitations of .NET 3.5.

Joannes Vermorel