Scott Hanselman

WSDL Cleanliness is next to Godliness (actually Cleavage is next to Cleanliness and Goggles is next to Godliness...)

June 10, '03 Comments [6] Posted in Web Services | ASP.NET | TechEd | Speaking | XML
Sponsored By

So let me start my own little possee here and cry: Say No to inline schema definitions in WSDL! Import is your friend.... [Commonality]

I'm with Tomas on this one. Schemas should be written as standalone documents and then be imported into the WSDL document. Not only is this easier to manage for the developer writing the schema and WSDL, but it's also easier for those who have to grok the two. Besides, the service you're writing the WSDL for probably isn't the only thing that's going to need access to the types you define in the schemas. [Drew Marsh]

Totally...not only WSDL First! and <xs:import> but (maybe this is obvious) I'm getting in the habit of putting the Domain Object-y definitions that we use elsewhere and the SOAP-y GetDomainObjectResult/Response definitions into separate XSDs.  I preached this at TechEd last week and spoke briefly to Tomas about it although we didn't have enough time to really dig in.

   <xs:import namespace="" schemaLocation="Account.xsd"/>
   <xs:import namespace="" schemaLocation="GetAccounts.xsd"/>

In this small example, the Account.xsd schema contains all sorts of Account-specific definitions that we may pass around internally to our app (on Queues, to functions, as objects, without SOAP) and GetAccounts.xsd contains definitions for GetAccountsResult and GetAccountsResponse and other useful "container" definitions in a separate namespace.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Wednesday, 11 June 2003 01:39:32 UTC
wouldn't you be better of using wsdl:import ?, then you don't need a types section at all.
Wednesday, 11 June 2003 06:21:27 UTC
I used the schema import because I was _sure_ that I wanted to import/reuse schema...I've seen some talk about the wsdl:import vs. xsd:import deal...(
Wednesday, 11 June 2003 06:22:03 UTC
I have to agree with Simon - I also prefer wsdl:import here.
Wednesday, 11 June 2003 11:26:16 UTC
It's also worth mentioning that the WS-I Basic Profile says you should only use xsd:import to import schemas. The rational is to keep the schema stuff together in on place (ie all in the wsdl:types section) and the rest of the stuff (operations, etc) outside that.

Wednesday, 11 June 2003 16:47:59 UTC
I have to agree with Jorgen and disagree with Simon and Christian. After the "wsdl:types" section, WSDL's job is responsibilities there are done and if I'm importing schema, I'll use xsd:import. If I'm importing split-up WSDLs from elsewhere I'll use wsdl:import. IMHO.
Thursday, 12 June 2003 14:40:09 UTC
OK, guys - after reading a bit ... lessons learned. Thanks for this hint, Jorgen!
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.