Scott Hanselman

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

June 10, 2003 Comment on this post [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.

 <wsdl:types>
    <xs:schema>
   <xs:import namespace="
http://banking.corillian.com/Account.xsd" schemaLocation="Account.xsd"/>
   <xs:import namespace="
http://banking.corillian.com/Banking/GetAccounts" schemaLocation="GetAccounts.xsd"/>
  </xs:schema>
 </wsdl:types>

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
Hosting By
Hosted in an Azure App Service
June 11, 2003 5:39
wouldn't you be better of using wsdl:import ?, then you don't need a types section at all.
June 11, 2003 10:21
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...(http://lists.w3.org/Archives/Public/www-ws-desc/2002Oct/0115.html)
June 11, 2003 10:22
I have to agree with Simon - I also prefer wsdl:import here.
June 11, 2003 15:26
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.

June 11, 2003 20:47
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.
June 12, 2003 18:40
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.