Adding comments to a WSDL output from WCF/.Net

喜你入骨 提交于 2019-12-18 12:12:47

问题


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:


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




回答2:


http://msdn.microsoft.com/en-us/library/aa717040.aspx

I think this will do what you want but it only will work for .NET clients.




回答3:


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




回答4:


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.




回答5:


[WebService(Namespace = "XXXXXXXXXXXXX", **Description**="V0.2.42")]

Description put whatever you want in the .NET 4.0, not sure which versions... Probably a little late in answering, but answers seem more complex than required to add a blurb to WSDL only devs see.



来源:https://stackoverflow.com/questions/655234/adding-comments-to-a-wsdl-output-from-wcf-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!