473,322 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

DataSet.ReadXml - where the schema name is?

RA
Hi

I have an xml schema and I have created a dataset from that schema.
I have a web service that recieve info and sends back an xml information.
I send back the xml using SchemaDataset.WriteXml (...)
A consumer of the web service then call a different method of the web
service which takes an xml string as an input parameter.
I need to load this xml string into the Schemadataset. I do that using the
following:

SchemaDataset.ReadXml (...)

My question is:

I assume that the dataset validated the xml string agianst its schema - well
then where does the dataset gets the schema from?
Here is the info that the web service method gets

<MyDatasetSchema xmlns=http://www.myweb.com/schema/MyDatasetSchema.xsd>
<StoreList>
<StoreId>5</StoreId>
</StoreList>
</MyDatasetSchema >

Thanks


Nov 21 '05 #1
1 1816
RA wrote:
I assume that the dataset validated the xml string agianst its schema
- well
then where does the dataset gets the schema from?


Well the problem is that that assumption is unfortunately wrong. If you wanted to validate the schema you need to put a XmlValidatingReader in the middle of your call to ReadXml. The next problem is, that if you want it to validate specific schemas you need to hook up a custom XmlResolver that helps locate those schemas. The default implementation tries to chase down namespaces URIs, but if the URI isn't a URL (or a URL that it supports natively) then it can't. Therefore you'll probably want to store the schemas in a well known location for your app and have a custom XmlResolver help resolve the schemas from that location.

So you end up with something like so:

<codeSnippet language="C#">
public void MyWebMethod(XmlElement incomingElement)
{
XmlValidatingReader reader = new XmlValidatingReader(new XmlNodeReader(incomingElement));
reader.XmlResolver = new MyCustomXmlResolver();

MyTypedDataSet myDataSet = new MyTypedDataSet();

XmlDataDocument dataDocument = new XmlDataDocument(myDataSet);
dataDocument.Load(reader);

... use dataset ...
}
</codeSnippet>

Now all that's left to do is to write MyCustomXmlResolver. For more details on writing a custom XmlResolver, have a look at this artcile on MSDN[1].

HTH,
Drew

[1] http://msdn.microsoft.com/library/de...omResolver.asp
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jeffrey A. Voigt | last post by:
I'm having trouble loading some xml data into a dataset via the ReadXML call. I'm loading into the dataset an xml schema prior to the ReadXML call. I see that there IS in fact, 3 records that...
2
by: MarkAurit | last post by:
How does one go about getting the information from an .xsd file into a WSDL document? I have a web service that creates a simple object that IBM Websphere can see and use. Great. However, when I...
2
by: C Glenn | last post by:
I'm attempting to use ReadXml. It's working in that I end up with some data in the DataSet. But I'm not able to deal with it effectively after that. The XML file is properly formatted in that it...
0
by: c.w.browne | last post by:
Hi, Ive had a bit of a look around for other people with this problem and cant find anything that solves it in my case, so I'm afraid im going to have to bother you all with a post of my own. ...
11
by: MurdockSE | last post by:
Greetings. My Situation: // I have an .xml file that I am reading into a dataset in the following code - DataSet ds = new DataSet("MyDataset"); ds.ReadXml(@"c:\data\"+cmyxmlfilename);
1
by: Mac | last post by:
I'm trying to validate input from an xml source to a dataset in dotnet2.0. As far as I can see, type errors correctly cause an exception, but values that are the correct type but do not satisify...
4
by: SteveT | last post by:
I am wanting to populate several treeviews, one for the <TRs> group and one for the <TGsgroup. Is there a simplier way to populate the Treeview than the one I did below? It seems difficult to...
1
by: Angel \Java\ Lopez | last post by:
Hi people! I'm running a Visual Studio 2005, Professional, on Windows XP Professional. I've found a little big problem, reading a DataSet. If I try: ds.ReadXml("c:\data.xml") it raises...
5
by: Lucvdv | last post by:
This would better be described by 'serialization' than 'interop', but I didn't find a newsgroup that seems closer on topic. The problem in a few words: I save data with DataSet.WriteXML, but I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.