This post originated from an RSS feed registered with .NET Buzz
by Christian Weyer.
Original Post: The Web services empire strikes back - Contract-first with .NET 'IDL'
Feed Title: Christian Weyer: Web Services & .NET
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/cweyer/Rss.aspx
Feed Description: Philosophizing about and criticizing the brave new world ...
Clemens thinks 'IDL' is good and often enough to hammer down your services interface and message contract - well somehow, yes. But we do not have to wait for Indigo, just some few months for Whidbey. Things really get better with ASMX v2 in Whidbey.
The following description assumes that you already have an exisiting WSDL (or a bunch of them) and then generate code from it. But the process can also be turned around: First code your interface in .NET and voila... you have the code-based contract-first approach rather than the schema-based one with XSD and WSDL.
ASMX v2 will generate a different interface for each binding in a WSDL description. E.g.:
Each interface has the WebServiceBindingAttribute with the binding's name and namespace. At runtime, ASMX reflects over the interfaces that a user's class implements to find all WebServiceBinding and WebMethod attributes. A class that implements an interface which has the WebServiceBindingAttribute can't itself have any Web services or XML serialization attributes. Makes sense but is very important! Obviously, a class can implement multiple interfaces each corresponding to a different WSDL binding, but a given binding cannot be split across multiple interfaces. If an interface inherits from another interface, at most one of the interfaces can have the WebServiceBindingAttribute. This is analogous to WSDL not allowing portType inheritance. The generated interface has the same name as the binding name and is prefixed with 'I' to indicate "Interface". Multiple bindings can be passed to the code generation process (e.g. with wsdl.exe) in one or more WSDL files. Each binding will then yield a different interface.
And as already stated at the beginning of this article: Just use this approach reversely and you are all set to design your contract-first Web services in 'IDL'.