Alternative to SvcUtil.exe? - wcf

I have been wrestling with SvcUtil all day, trying to get it to generate useful code for some IMS Enterprise Services (primarily Group Management Service, but there are others we need it to work for as well.) You can find the IMS service WSDL's here http://www.imsglobal.org/es/index.html.
I have come to the conclusion that SvcUtil is a useless afterthought from Microsoft that doesn't support the WSDL and XSD standards even in a half-assed way. It is incapable of generating a WCF service that conforms to the standard WSDL contracts that IMS uses AND functions at the same time. Despite generating compilable code from the following WSDL (http://www.imsglobal.org/services/gms/wsdl/imsGroupManServiceSync_v1p0.wsdl), observing the generated WSDL from the WCF service (?wsdl, ?wsdl=wsdl0, ?xsd=xsd0, etc.) shows that none of the operations exist, and only a fraction of the types that were generated in code are actually recognized by WCF. If we screw with the generated code, we can get something that sort of functions (we are using SoapUI to test), but then it no longer conforms to the contract, so its useless to the people who really need to call these services.
Are there any alternatives to SvcUtil? (Please don't suggest the built in Visual Studio "Add Service Reference" tool, that is just as useless as it uses the exact same code as SvcUtil.) We need something that will give us a degree of control over how code is generated from the WSDL contract, what files each part ends up in, which namespaces each code element ends up in, etc. The IMS contract imports both XSD types specific to the services defined in the WSDL, as well as XSD types that are common to all IMS services. We need to be able to generate different assemblies for those types, and reference them in the generated code (similar to how SvcUtil is apparently supposed to do it...but it doesn't seem to do what it says its documentation says it does at all.)
I have been a huge fan of WCF until now. It obviously works when you use only .NET/WCF services, but any time you try to use it in a standards-compliant, cross-platform environment, everything goes to shit.

Have you had a look at the WCF Proxy Generator on Codeplex? Based on who's behind it (Kate Gregory and Michele Leroux Bustamante), there's hope it might be useful - plus you get the sources, so you can adapt / tweak at your heart's content!
(haven't had the time to take a serious look at it myself - yet - it's on the endless "To-Do when I get around to it" list....)
Plus check out this blog post here by Pedram Rezaei showing how to influence the Visual Studio "Add Service Reference" step with your own custom code.

Sorry that I don't have time in full to reply to this but there is an answer to your question. There is an interface that you can implement called IWsdlImportExtension which has two methods that you will be interested in. They are:
GenerateContract() and GenerateOperation()
If you implement these methods, you can actually control the way SvcUtil pumps out code by adding or removing CustomAttributes and so on. You need to compile a dll with the interface in it and then point the SvcUtil configuration at the DLL and the interface.
Using this method, you can can for example add Xml documentation to your outputted proxies and so on. There are some interested articles around about this.

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.

What tools to use to generate service code from schemas (svcutil analogue), if they do not meet the DataContractSerializer requirements

We are working on SOA, both on client (Silverlight) and server (WCF) sides, but with possibility of the clients being implemented by 3rd parties (.NET, Java, etc.). We use WSDL-first approach and want our data and services interface classes (C#) to be automatically generated from schemas during build process. So we need common data classes code not being regenerated for every service for successful compilation.
I have tried the svcutil utility, trying to first create all data contract classes from XSDs with the /dataContractOnly switch, and compile them to separate class library - the first stage. And then to create each service interface code, omitting the classes already in the library, with the /reference switch - the second stage.
The problem is that our schemas do not meet the DataContractSerializer requirements, so svcutil cannot create data classes. Even after I used xsd utility for this purpose, I cannot use svcutil's /reference switch on the second stage, since this switch only works for DataContract classes. And this is not the case with the classes generated by xsd utility.
So, am I missing something with these tools and are there any way to use them in my situation, or are there any other tools to generate data classes and service interfaces from XSD and WSDL schemas, in case where common data types are used by several service interfaces? Or should we hardly limit ourselves with DataContract compatible schemas? What approach do you use for WSDL-first development?
Have you tried WCF.blue tool by codeplex?
WSCF.blue is a toolset that facilitates the development of web services using a contract first (specifically, a schema first) approach. This is the WCF version of the orginal Web Services Contract First tool.
Also, there is a beautiful article on Contract-First development:
http://msdn.microsoft.com/en-us/magazine/ee335699.aspx
Yes WSCF.Blue is a VS plugin as it ships but the source is available and so it can be rebuilt into a command line interface version like what we had to do, with little effort required I might add.

What alternitives are there to WCF Test Client?

I feel like it should be easier to test my WCF Services.
Is there an alternative to WCF Test Client?
Something with these features:
Can save my object trees (method parameters) to be used again.
Ideally it would even let me identify GUIDs that need to be re-generated on each run and ones that should stay static.
Easier to deal with arrays, lists and nullable types. (For example, if I have an array of nullable types, I have to enter the length of the array and that that each one is not null before I can fill in values. It just seems that there should be an easier way....)
Can save the "Config File" between runs. (My services return more data than the standard 65,536 in MaxBufferSize and MaxReceivedMessageSize.)
Free is best, but if I have to pay to get a good tool I will consider it.
I use WCF Storm LITE to test my WCF services. It's more user-friendly than WCF Test Client, although the free version has limited features compared to its commercial counterpart.
SOAPUI is the best I found so far. It can even be used to test RESTful services as well.
It has a community edition (free) and a pro edition. AFAIK, the community edition is not feature restricted. The benefits of Pro edition, besides the technical support, is the time-saving features like database-driven requests and nice UI editor for composing the request. In the community edition, you'll have to get your hands dirty and work with the xml.
http://www.soapui.org
I am the developer of an opensource tool called WsdlUI that can be used instead of WCFTestClient. It can be integrated into Visual Studio to use instead of WCFTestClient.
It can be downloaded at https://drexyia.github.io/WsdlUI/.
To use it with Visual Studio:
Go to project properies -> Debug page
Change Command Line Arguments
From: /client:"WcfTestClient.exe"
To: /client:"[PATH]WsdlUI.exe"

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.