Data contract generation is now available in WSCF.blue

by Alex Meyer-Gleaves 1 September 2009 - 7:47 PM

I am pleased to report that data contract generation is now available, and that the functionality has been extended to allow the selection of multiple source XSD or WSDL files. This feature is available in the V1 Beta 2 release, and as always, user feedback and bug reports are welcome.

Data contract generation was one of the features from WSCF.classic that got left behind while the work was done to support WCF in WSCF.blue. Since this was a very popular feature it was important to make sure it was available in WSCF.blue as part of the V1 release.

The generated data contract types are designed to work with the XmlSerializer. WSCF.blue uses the XmlSerializer because the DataContractSerializer is limited in regards to its support for many of the XSD constructs that often appear in contract-first WSDL. Regardless, I would like to add the ability to generate data contract types using the DataContractSerializer. Please let me know if this is a feature you would like to see implemented.

To generate data contracts start by selecting the required XSD or WSDL file in your project. You can select one or more files as required.

Source XSD files.

Right-click your selection and choose Generate Data Contract Code... from the context menu.

Generate Data Contract Code...

You will be presented with the Data Contract Code Generation Options dialog.

Data Contact Code Generation Options

You can choose to create a separate file for each type or keep them all in a single file. The usual list of Code generation options are also available. Click Generate and enjoy your data contracts!

Tags: ,

Web Services | WSCF

Comments (7) -

Tobias Manthey
Tobias Manthey
9 February 2010 - 4:41 AM #

Hi,
I definitly would like to have the choice to generate data contract types using the DataContractSerializer. Even though it is quite limited in the XSD features you can use, you can model nearly any structure you intend to. svcutil /dconly even supports inheritance.
Thanks for your work on WSCF.blue!
Cheers,
Tobias

Reply

Alex Meyer-Gleaves
Alex Meyer-Gleaves
11 February 2010 - 9:52 AM #

Hi Tobias,

Thanks for the feedback. It is appreciated. Support for the DataContractSerializer is definitely on the roadmap. The current thinking is that we would use it by default, and fall back to the XmlSerializer only when the XSD contains constructs that are not supported by the DataContractSerializer.

Alex.

Reply

James
James United Kingdom
25 April 2013 - 2:34 AM #

Hi,

We use WSCF.blue in our project and we still use .NET 3.5 and VS2008.
I'm experimenting with generating DataContract wrappers for our Xsd contracts instead of the default XmlSerializer classes.

This might just be my lack of understanding, but using either the Generate Data Contract option or Generate Web Service options generate by and large identical code.

The only difference is the Data Contract option has one extra attribute:
[System.Xml.Serialization.XmlRootAttribute(Namespace="urn:www.test.com:datacontracttest", IsNullable=false)]

Shouldn't they have [DataContract] attributes?

Reply

Alex Meyer-Gleaves
Alex Meyer-Gleaves Australia
26 April 2013 - 6:25 PM #

Hi James,

The Generate Data Contract option means that only the data contract types will be generated, not that the DataContractSerializer will be used. WSCF.blue does not currently support the DataContractSerializer though it was in the pipeline. The XmlSerializer was originally chosen because it supports as wider range of the XSD specification.

Cheers,

Alex.

Reply

James
James United Kingdom
27 April 2013 - 2:01 AM #

Hi Alex,

Thanks for the response.
I was hoping to find a cheap way to trick the WCF client proxy generator to use data contracts so we get List<T>s instead of Arrays.
Guess I'll just have to wait until doomsday for us to move up to .Net 4.5 and it's native contract first development!
(I'm like a child with my nose pressed up against the toy shop window)

Reply

Alex Meyer-Gleaves
Alex Meyer-Gleaves Australia
27 April 2013 - 10:10 PM #

What version of .NET are you using? The contract-first support in .NET 4.5 is essentially the same as what is generated for a client, except only the interface is generated and not the client proxy. You should be able to use the /collectionType:<type> switch on svcutil.exe to specify the List<T> collection type.

Reply

James
James United Kingdom
29 April 2013 - 7:05 PM #

VS2008 and .NET 3.5

Never used the svcutil method, always just added a "Service Reference". I use the "List<T>" setting in the advanced box of the service ref. I'll test to see whether the command line option does anything different.

We have an option to move to .NET 4.0, will have to test if that gets us anything better.

Thanks,

J.

Reply

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

About the author

Alex Meyer-Gleaves I'm a Technical Architect living in Australia (that island like continent in the southern hemisphere). I love Microsoft .NET and C#. I hate early mornings, slow drivers and Lotus Notes.

Twitter

Google Shared

 

Month List

Recent Comments

Comment RSS

Links

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010