Geek Noise
Rants, rambles, news and notes by Peter Provost
05

More About DataSets and Interop

Friday, 5 September 2003 08:16 by Peter Provost

Gordon Weakliem comments:

I don't get your comment about "vague concerns over interoperability". Name a non-Microsoft SOAP stack that can serialize a DataSet. I don't know of any. I'd call that a real concern over interoperability. AFAIK, the schema for the DataSet wire format isn't publicly available

I guess what I meant was that I didn't have any hard evidence about it. It felt wrong precisely because I didn't know if a non-MS SOAP stack could deserialize it.

Now since the schema for a particular DataSet is available via the WriteXmlSchema method, I decided to find out how hard it would be... it seems to me that you should be able to deserialize it in any language.

To see what a DataSet schema looks like, I fired up Snippet Compiler and entered the following code:

using System;

using System.Data;

public class MyClass
{
public static void Main()
{
DataSet ds = new DataSet();
DataTable table = ds.Tables.Add( "MyTable" );
DataColumn col1 = table.Columns.Add( "Col1", typeof(System.String) );
DataColumn col2 = table.Columns.Add( "Col2", typeof(System.Int32) );

table.Rows.Add( new object[] { "a", 1 } );
table.Rows.Add( new object[] { "b", 2 } );

ds.WriteXml( "C:\\dataset.xml" );
ds.WriteXmlSchema( "C:\\dataset.xsd" );
}
}

I ran the code and got the following XSD file:

xml version="1.0" standalone="yes"?>
<xs:schema xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" 
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns=""
id="NewDataSet"> <xs:element name="NewDataSet" msdata:IsDataSet="true"> <xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:element name="MyTable"> <xs:complexType> <xs:sequence> <xs:element name="Col1" type="xs:string"
minOccurs="0"/> <xs:element name="Col2" type="xs:int"
minOccurs="0"/> xs:sequence> xs:complexType> xs:element> xs:choice> xs:complexType> xs:element> xs:schema>

And the following XML file:

xml version="1.0" standalone="yes"?>
<NewDataSet>
  <MyTable>
    <Col1>aCol1>
    <Col2>1Col2>
  MyTable>
  <MyTable>
    <Col1>bCol1>
    <Col2>2Col2>
  MyTable>
NewDataSet>

So it seems to me that anyone who wanted to could deserialize a DataSet, because it is essentially just an XML Infoset at heart. The problem with using DataSets in Web Services is not that they are proprietary, but that the way they are defined in the WSDL is bad. I think maybe you could solve this with a WSDL First approach, but I'm not sure.

Anyone?

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Technology
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed