{"id":1058,"date":"2004-07-14T20:35:00","date_gmt":"2004-07-14T20:35:00","guid":{"rendered":"\/blogs\/bobb\/post\/About-Web-Services-and-Schema-2b-Any.aspx"},"modified":"2015-08-08T09:35:35","modified_gmt":"2015-08-08T16:35:35","slug":"about-web-services-and-schema-any","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/bobb\/about-web-services-and-schema-any\/","title":{"rendered":"About Web Services and &#8220;Schema + Any&#8221;"},"content":{"rendered":"<p>\nAbout a month ago, there was another chapter in the long discussion about DataSets and web services. An old cohort Scott Hanselman fired off <a href=\"http:\/\/www.hanselman.com\/blog\/PermaLink.aspx?guid=d88f7539-10d8-4697-8c6e-1badb08bb3f5\">the first salvo<\/a>, which&nbsp;was taken up by Ted Neward. Doug Purdy responds that Purchase Orders are root of all evil&nbsp;and lots of other chimed in. I&#39;m just catching up&#8230;\n<\/p>\n<p>\nThis comes up again as I work with SQL Server 2005 web services. They too produce &ldquo;SqlRowset == Schema + Any&quot; in WSDL. Both XML and object afficianados tend to dislike this, but it exactly reflects the relational resultset, rowset, whatever you&#39;d like to call it.\n<\/p>\n<p>\nRelational results are columns and rows, where each row contains the same number of columns and each column contains the same data type for each row. Been around for a while now. The resultset is a &quot;generic container class&quot; or special 2-dimensional array if you want to think in those terms, in which each instance can contain different types, but the shape is rectangular. Resultsets, looking at an Open Data Services program which makes the protocol explicit, are preceeded&nbsp;by a sequence of describe packets that contain the name, data type, and other information about each column. So &quot;Schema + Any&quot; means exactly that. *Instance* schema, followed by the instance it describes. Corresponds quite nicely with relational databases, where the majority of corporate data is stored.\n<\/p>\n<p>\nThe problems stem from the fact that lots of web services toolkits, that are doing XML-to-Object mapping, don&#39;t recognize this paradigm. They are looking for an individual (static) schema, not an instance (dynamic) schema.&nbsp;In addition, the&nbsp;XML Schema spec states that how you find a schema from an instance of an XML document is implementation dependent. It mentions a hint (xsi:schemaLocation) and some location strategies for schemas with namespaces that are URLs,&nbsp;but says processors don&#39;t have to support the hint. Most WSDL that uses &quot;Schema + Any&quot; doesn&#39;t provide the hint. With Microsoft XML processors, this may be because &quot;Schema + Any&quot; is part of the implementation, an &quot;implementation dependent&quot; location strategy.\n<\/p>\n<p>\nThere&#39;s a few ways to resolve this, if you&#39;re looking for strongly typed objects at compile time. One way is strongly-typed DataSets, which fetch out the information at compile time, make a DataSet wrapper class, and, for web services, write WSDL that amounts to &quot;Any from a specific namespace&quot;, and import the namespace schema, which includes the strong type. Another way is to write your own WSDL for each resultset.\n<\/p>\n<p>\nIf you write a stored procedure in SQL Server that looks like this:\n<\/p>\n<p>\nCREATE PROCEDURE getauthors<br \/>\nAS<br \/>\nSELECT au_id, au_fname, au_lname FROM authors\n<\/p>\n<p>\nyou know exactly what that resultset will look like. Unless the DBA changes the column type, in which case you&#39;ll have other problems. Even if you use the &quot;SELECT * FROM &#8230;&quot; concept (which is not usually recommended) this works unless the DBA adds or deletes a column, or changes the order of definition. I haven&#39;t been able to find a metadata table in SQL Server (or in the ANSI\/SQL spec) that lists the shape of all resultsets returned by stored procedures (there is one for *parameter* information) , so you have to use your knowledge of the resultset to handcraft the WSDL. In ADO.NET, you can use the DataSet&#39;s &quot;WriteXmlSchema&quot; method as a starter. Or use &quot;SET FMTONLY ON;SET NO_BROWSETABLE ON;EXECUTE&#8230;&quot;. SQL Server 2005 web services that map stored procedure invocation to web service methods will let you specify a custom WSDL-generating stored procedure. Statically store the metadata (instance schemas) in the database or dynamic generate them at WSDL generation time.\n<\/p>\n<p>\nBTW, this mapping of resultsets to XML schemas amounts to relational-to-XML mapping. So web service toolkits can accomplish their XML-to-object mapping. I&#39;ll return to this theme in future&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>About a month ago, there was another chapter in the long discussion about DataSets and web services. An old cohort Scott Hanselman fired off the first salvo, which&nbsp;was taken up by Ted Neward. Doug Purdy responds that Purchase Orders are root of all evil&nbsp;and lots of other chimed in. I&#39;m just catching up&#8230; This comes [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28,37],"tags":[],"class_list":["post-1058","post","type-post","status-publish","format-standard","hentry","category-sql-server-2005","category-sql-server-xml"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.9.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>About Web Services and &quot;Schema + Any&quot; - Bob Beauchemin<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/about-web-services-and-schema-any\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"About Web Services and &quot;Schema + Any&quot; - Bob Beauchemin\" \/>\n<meta property=\"og:description\" content=\"About a month ago, there was another chapter in the long discussion about DataSets and web services. An old cohort Scott Hanselman fired off the first salvo, which&nbsp;was taken up by Ted Neward. Doug Purdy responds that Purchase Orders are root of all evil&nbsp;and lots of other chimed in. I&#039;m just catching up&#8230; This comes [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/about-web-services-and-schema-any\/\" \/>\n<meta property=\"og:site_name\" content=\"Bob Beauchemin\" \/>\n<meta property=\"article:published_time\" content=\"2004-07-14T20:35:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-08-08T16:35:35+00:00\" \/>\n<meta name=\"author\" content=\"Bob Beauchemin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bob Beauchemin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/about-web-services-and-schema-any\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/about-web-services-and-schema-any\/\",\"name\":\"About Web Services and \\\"Schema + Any\\\" - Bob Beauchemin\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\"},\"datePublished\":\"2004-07-14T20:35:00+00:00\",\"dateModified\":\"2015-08-08T16:35:35+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/about-web-services-and-schema-any\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/bobb\/about-web-services-and-schema-any\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/about-web-services-and-schema-any\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server 2005\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/sql-server-2005\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"About Web Services and &#8220;Schema + Any&#8221;\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\",\"name\":\"Bob Beauchemin\",\"description\":\"SQL Server Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\",\"name\":\"Bob Beauchemin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"caption\":\"Bob Beauchemin\"},\"sameAs\":[\"http:\/www.sqlskills.com\/blogs\/bobb\/\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"About Web Services and \"Schema + Any\" - Bob Beauchemin","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/bobb\/about-web-services-and-schema-any\/","og_locale":"en_US","og_type":"article","og_title":"About Web Services and \"Schema + Any\" - Bob Beauchemin","og_description":"About a month ago, there was another chapter in the long discussion about DataSets and web services. An old cohort Scott Hanselman fired off the first salvo, which&nbsp;was taken up by Ted Neward. Doug Purdy responds that Purchase Orders are root of all evil&nbsp;and lots of other chimed in. I&#39;m just catching up&#8230; This comes [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/about-web-services-and-schema-any\/","og_site_name":"Bob Beauchemin","article_published_time":"2004-07-14T20:35:00+00:00","article_modified_time":"2015-08-08T16:35:35+00:00","author":"Bob Beauchemin","twitter_misc":{"Written by":"Bob Beauchemin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/about-web-services-and-schema-any\/","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/about-web-services-and-schema-any\/","name":"About Web Services and \"Schema + Any\" - Bob Beauchemin","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website"},"datePublished":"2004-07-14T20:35:00+00:00","dateModified":"2015-08-08T16:35:35+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/about-web-services-and-schema-any\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/bobb\/about-web-services-and-schema-any\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/about-web-services-and-schema-any\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/"},{"@type":"ListItem","position":2,"name":"SQL Server 2005","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/sql-server-2005\/"},{"@type":"ListItem","position":3,"name":"About Web Services and &#8220;Schema + Any&#8221;"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/","name":"Bob Beauchemin","description":"SQL Server Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e","name":"Bob Beauchemin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","caption":"Bob Beauchemin"},"sameAs":["http:\/www.sqlskills.com\/blogs\/bobb\/"],"url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/1058","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/comments?post=1058"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/1058\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/media?parent=1058"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/categories?post=1058"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/tags?post=1058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}