svcutil and Description attribute - wcf

When I use SvcUtil to generate the client-side class it does not include the "Description" attribute from the server-side class.
How to do this ?

Unfortunately, you'll be doing a lot of "heavy lifting" to include documentation in generated client code. SvcUtil does not support generating description/documentation from the WSDL.
To accomplish this manually, you need to implement a custom WSDL importer as shown in this good MSDN article on the subject. Lucky, there is a code sample in the WCF 4 code samples library showing how its done.

Related

How to generate code for WCF with svcutil and xsd files?

I have a set of xsd files that define an XML message protocol for communications between devices. I'm planning to use WCF at one end. I'm hoping that there is a way to automate generation of classes based on the xsd files that I could use with WCF. Am I on the right track?
I'm aware of svcutil.exe and xsd.exe but a quick try gave me somewhat disappointing results. For example, "svcutil /dconly" command generated C# classes that contained only code related to xml serialization (e.g. WriteXml(), ReadXml(), etc.). There were no other properties generated.
This is not the only problem that I'm facing. Even if I succeed with generation of code from xsd I will still not be sure how to plug it into WCF.
Could someone please give some general idea how to deal with it? A simple example or a pointer to one would be greatly appreciated.
Thanks.
What you need to generate WCF service or client code using svcutil is a wsdl file. The wsdl describes the name of the service, witch methods will be available and references the xsd files witch contain the description of your data.

How to programmatically create WCF service by using existing WSDL file?

I have WSDL file and XSD files and need to programmatically create WCF service.
Programmatically means without using any utility tool such as SvcUtil.exe.
What's my problem here..??
I haven't found anything like that on internet.
I know how to create WCF service using ChannelFactory, but I don't know how to employ existing WSDL file in such a scenario.
There's something about using IXmlSerializable interface and its GetSchema, ReadXml and WriteXml methods, but I'm not sure how to use it.
Thank you in advance.
Goran
SvcUtil.exe doesn't do anything "magical" that you can't do yourself in your own code; It uses public WCF classes to process WSDL and XSD, you can use the exact same classes (for example, System.ServiceModel.Description.WsdlImporter), but unfortunately it's not very easy. Read http://msdn.microsoft.com/en-us/library/ms731768.aspx and its subtopics as a starting point. You can also open up SvcUtil.exe itself in Reflector to look at its code and see how it does certain things. I think there are also some open-source implementations of a "better svcutil", you can look at their code as well, unfortunately I can't remember any details at the moment.

Create flattened WSDL using svcutil for wcf 4

I need to create a wsdl without the extras xsd files as external files, but have them all inside a single file. I need this because they will be imported by Delphi's WSDL importer, that is quite out-of-date. Can I do this using svcutil.exe? If it's not possible with svcutil, is there any way to do this? I have seen very old samples, based on WCF 3.5, but I don't know if they still apply.
Tks so much
This seems to be a popular topic this week. There are several articles on how to generate flattened wsdl but this article should get you started. The code in the article will work for WCF 4. For the actual code to create the behavior this (unrelated) blog post is pretty much all this needed.

Generating RESTful API documentation from a WCF Service

I've recently started on a project to build out a RESTful API in WCF, and I'm going to need to expose documentation along with the API itself. I was hoping to leverage the XML code comments in my docs for this documentation.
But what I want to output is just the contracts that are exposed by the service: the endpoints and the JSON/XML object structures. Since I'm trying to create external documentation, I'm interested in any of the internals of my library, or how it ties into the .Net Framework (or even that it is .Net, for that matter).
What are my options for tools, to create these docs? I've heard that Sandcastle or Doxygen are good tools for generating docs from XML code comments, but can I filter away the classes and methods that I don't want to expose?
I understand this question was asked pre-.NET 4.0, but as of .NET 4.0, you can create a 'help page' as as described in WCF Web HTTP Service Help Page.
WCF 4.0 Example
[System.ComponentModel.Description("Triggers Method Name Behavior.")]
public void MethodName() {}
Sure, you can filter unwanted APIMembers with Sandcastle. This blogentry describes how. If you are new to Sandcastle, you might want to try out Sandcastle Help File Builder as well, which is basically a Sandcastle Frontend.
You could config doxygen to generate document from files speficied. Why not have a look a the documents of doxygen?

Adding comments to a WSDL output from WCF/.Net

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
It seems that the community project WCFExtras on GitHub provides a work-around the limitations of .NET 3.5.
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
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.
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.
[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.