A few thoughts on "The Perils of WSDL First"

Service Station, by Aaron Skonnard

Syndication

Craig recently wrote about his experiences using a contract-first approach to building Web Services. He called it The Perils of WSDL First. Craig essentially urges anyone starting with WSDL to implement IXmlSerializable on their types given the lack of control over element order in XmlSerializer 1.1. Tim responded saying what Craig urges is overkill.
 
Although what Craig describes is definitely an issue, I agree with Tim that you don't have to go nearly that far. In fact, I know many customers who have succesfully built services using a WSDL-first approach without having to know hardly anything about the System.Xml.Serialization stack. What did they do differently?
 
They relied on a code-generator (xsd.exe) to produce the serializable types used at the edges of the system (the external types) -- and they considered this code immutable -- they only change it when there's a change to the WSDL definition and they need to regenerate the whole service layer. Then they manually defined internal (domain specific) types, with all the bells and whistles they desired along with transformation logic for moving between the internal/external types. This is basically what Craig suggests you should do in his set of rules at the bottom of his post.
 
Doing this guarantees that the external "serializable" types will always produce the correct XML as defined by the original schema, but within the business/data layers you can use friendlier types to your liking (e.g., different member order, helper methods and properties, etc). It also allows you to host multiple service endpoints, each supporting a different WSDL version, but all endpoints are implemented against the same internal domain-specific types. If you use this approach, you won't experience the problem Craig describes.
 
In general, I consider it a no-no to modify any code generated from WSDL if you're sharing the original WSDL definition with consumers -- there are just too many things that can cause violations to the contract, order being one of them.
 

Posted Apr 18 2006, 02:32 PM by Aaron Skonnard
Filed under: ,

Comments

Craig wrote re: A few thoughts on "The Perils of WSDL First"
on 04-18-2006 12:01 PM
So what about all those people that don't bother with the internal/external split? Which is 99% of them. :) I agree this split is a great idea - I've been burned by it in the real world at least once.

Also, I should point out that in our case we couldn't generate types from the schema.
Aaron Skonnard wrote re: A few thoughts on "The Perils of WSDL First"
on 04-18-2006 1:38 PM
Those who don't bother with the split are in for a bunch of other fun problems down the road. ;-) At first, it may feel like a lot of duplication in smaller/new systems, but for traditional distributed systems that were built using a multi-layer approach, it's actually a very natural transition. You're just adding an extra layer (the "service" layer) on top of what you already have.

If 99% of the people out there are really doing things the way you suggest, that illustrates how little people are thinking about architecture, maintenance, and versioning before jumping into the "services" game. But you could be right -- it does feel like the whole SO design arena is still in its infancy. You know, this sounds like a great topic for a .NET architecture course...do you know where I could find one?

Just curious, why weren't you able to generate your types from the XSD?
Julie Lerman Blog wrote The great WSDL debate
on 04-18-2006 2:30 PM
CraigBlog wrote The Perils of WSDL First (Again)
on 04-19-2006 7:59 AM
Jason Haley wrote Interesting Finds
on 04-19-2006 11:04 AM
Robert wrote re: A few thoughts on "The Perils of WSDL First"
on 04-24-2006 11:40 AM
Aaron, this is a very interesting discussion, however, in what Craig describes with the location attribute on the WSBinding attribute doesn't appear to exist in WCF? In other words, how to dynamically bind to a wsdl file in WCF?

Thanks
All About Interop wrote WSDL First Best for Interop, but... at what cost?
on 05-01-2006 3:25 PM
While doing my random walk I found this recent post by Aaron Skonnard.  Good topical commentary...

Add a Comment

(required)  
(optional)
(required)  
Remember Me?