Updates in red.
Yasser Shohoud, in the December 2002 issue of MSDN Magazine, advocates constructing WSDL before WebService classes, along with instructions on how to shoehorn the technique into Visual Studio. The “WSDL First” mantra also gets mention in a sidebar in Keith Ballinger's excellent book, .NET Web Services: Architecture and Implementation with .NET.
I've always been an advocate of using tools the way they “want” to be used. Visual Studio does not “want” to develop Web Services in a “WSDL First” way. I would certainly agree that the WSDL layout is paramount. However, perhaps this can be accomplished by starting with the methods and classes but remaining cognizant of the WSDL layout. There are a lot of WSDL controls available by using XML Serialization attributes and heavy use of the Web Services attributes. I'm not certain, in the face of maintenance and heterogeneity, which is the best method. However it is clear that the difficulties of “WSDL First” lay in these areas:
- It is difficult to design in WSDL and XML Schema
- Visual Studio is not set up well to work with “WSDL First”
- The mapping between objects and XML Schema can be quite indirect
While the first problem can be ameliorated through XML design tools such as xmlspy, as described in Aaron Skonnard's The XML Files column, these tools are not well integrated in to Visual Studio ASP.NET Web Services. Keith Short does explain that Whitehorse will have some kind of “Contract First” support. However, such a facility was not mentioned in The .NET Show interview with Steve Swartz about Indigo programming (transcript) (video).
In the end a tool cannot solve the problem. The core problem is that there is no clean mapping between XML Schema and CLR. This was initially addressed by Don Box in the first installment of the House of Web Services column in MSDN Magazine. In a later issue of MSDN Magazine, the ever resourceful Aaron Skonnard tried to address some of the concerns. Some of these concerns are addressed in detail by the research team behind the Xen language.
Dare Obasanjo concludes that it is by far easier to start with CLR types for the mapping than from XML Schema. Doug Purdy agrees. Doug Purdy address the issue of mapping between the type systems directly in his PDC Presentation, Indigo: Using XSD, CLR Types, and Serialization in Web Services.
Of course one could posit that we should just stay in XML. To me that doesn't hold water. I hold out hope for the day that a Xen derivative saves us from this problem. Until then, I think I'll start with classes.
Update: Dino Chiesa, a Microsoft marketing PM for .NET, makes a very good point. Dare has already provided guidelines on what parts of XSD can be modeled in CLR. Certainly the same can be done for Java. The intersection of those subsets would constitute good WSDL parameter objects. More importantly a tool can be devised to produce or verify that that subset were used. Here's your chance, Microsoft, to give us the power!