Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
XML To Dataset
Message
De
20/03/2008 11:11:38
 
 
À
20/03/2008 08:47:53
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Divers
Thread ID:
01303148
Message ID:
01303904
Vues:
24
>Hmmmmm... you're right. Woops. What the heck was I thinking?
>
>You didn't just turn big and green and flung a vehicle, did you? :-)


Ooops, my secret is out! Shhhhhh!

~~Bonnie


>
>>Arrrggghhh!! You guys are making this way too complex! DataSet.GetXml() returns exactly what you posted Viv:
>>
>>
>><?xml version="1.0" encoding="utf-8" ?>
>><People>
>>  <Person>
>>    <FirstName>Fred</FirstName>
>>    <LastName>Bloggs</LastName>
>>  </Person>
>>  <Person>
>>    <FirstName>Joe</FirstName>
>>    <LastName>Smith</LastName>
>>  </Person>
>></People>
>>
>>
>>~~Bonnie
>>
>>
>>
>>
>>>>>>>>I'm doing an app which is initially a C# WinForms app where the users will connect via VPN.
>>>>>>>>At some point in the future it will be converted to a web app, so I want to use a WS up front.
>>>>>>>>
>>>>>>>>I'm fairly new at this, and I've seen some examples, as well as prior postings with you and Bonnie
>>>>>>>>that got me going this way.
>>>>>>>>
>>>>>>>>I didn't think you could pass a dataset through a WS into the back end.
>>>>>>>
>>>>>>>.NET to .NET you can pass pretty much anything. As long as the client understands the type it can be completely transparent.
>>>>>>>
>>>>>>>But, as I said to Mike, if you anticipate that non-NET clients will be using your WS then passing back a DataSet as XML is not particularly consumer friendly.
>>>>>>>OTOH (and I don't know if it's just me but) I find I'm dealing with a lot of web services that do just that. Great if you're a .NET consumer; pain if you're not......
>>>>>>
>>>>>>
>>>>>>Not sure I understand. You're saying that XML is not consumer friendly?
>>>>>
>>>>>I'm saying a DataSet converted to XML is not friendly for a non-.NET consumer.
>>>>>
>>>>>If your web service returns a Dataset object it is automatically converted to XML by the .NET plumbing (so there's not much point in going through the .WriteXML() step). A .NET client can simply cast this back to a Dataset which is great. But a non-.NET client if faced with parsing an overly complex and verbose piece of XML when a far simpler representation of the data could be provided
>>>>>HTH,
>>>>>Viv
>>>>
>>>>Such as?
>>>For example this:
>>><?xml version="1.0" encoding="utf-8" ?>
>>><People>
>>>  <Person>
>>>    <FirstName>Fred</FirstName>
>>>    <LastName>Bloggs</LastName>
>>>  </Person>
>>>  <Person>
>>>    <FirstName>Joe</FirstName>
>>>    <LastName>Smith</LastName>
>>>  </Person>
>>></People>
>>>
instead of:
>>>  <?xml version="1.0" encoding="utf-8" ?>
>>> <DataSet xmlns="http://tempuri.org/">
>>> <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
>>> <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
>>> <xs:complexType>
>>> <xs:choice minOccurs="0" maxOccurs="unbounded">
>>> <xs:element name="People">
>>> <xs:complexType>
>>> <xs:sequence>
>>>  <xs:element name="FirstName" type="xs:string" minOccurs="0" />
>>>  <xs:element name="LastName" type="xs:string" minOccurs="0" />
>>>  </xs:sequence>
>>>  </xs:complexType>
>>>  </xs:element>
>>>  </xs:choice>
>>>  </xs:complexType>
>>>  </xs:element>
>>>  </xs:schema>
>>> <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
>>> <NewDataSet xmlns="">
>>> <People diffgr:id="People1" msdata:rowOrder="0" diffgr:hasChanges="inserted">
>>>  <FirstName>Fred</FirstName>
>>>  <LastName>Bloggs</LastName>
>>>  </People>
>>> <People diffgr:id="People2" msdata:rowOrder="1" diffgr:hasChanges="inserted">
>>>  <FirstName>Joe</FirstName>
>>>  <LastName>Smith</LastName>
>>>  </People>
>>>  </NewDataSet>
>>>  </diffgr:diffgram>
>>>  </DataSet>
>>>
>>>Admittedly in this case it would make more sense to return a DataTable rather than a DataSet but.....
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform