472,983 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Strange error validating XML against XSD

Hello,

I've developed a .NET C# web service; which has one method named, let's say,
upload_your_data. This method has one parameter ( string your_data). The
value that this parameter will actually have is the content of a XML
document. This data will be processed and check for a well-formed xml
document and will be validated against a XSD. Before putting my code, let me
go on and explain the whole situation.

This web method is invoked by some guys outside my organization and they are
using java applications (jsp's … it seems to be).
I've tested my web method locally (intranet) from the test page (the one
with the "invoke" button) and works fine. Also, I have tested my web service
using a .NET Windows App which loads a XML file and invokes the web method to
upload the content of the file and works perfectly. Moreover I tested the web
service with this windows app from my home connected to the internet via my
ISP and invoking the web method directly from my company's web server. This
test was also completed successfully.
And, if this is not enough testing, I enabled the httpget and httppost
methods to enable the web method to be tested remotely using the test page.
I've done this with some of my friends.

However these guys from this other company, have a java application which
invokes my web method and it fails exactly when the XSD is performed. It
throws this error: The data at the root level is invalid. Line 1, position 1.

If, for example the content of the XML is simply:

<?xml version="1.0" encoding="UTF-8"?><my_root_tag>this is my
name</my_root_tag>

I receive exactly that string (I check the value of the web method's
parameter: your_data, which is a string variable) when testing the web method
with my testing apps. But when these guys invoke the method, the value that I
get from them is:

<?xml version="1.0" encoding="UTF-8"?><my_root_tag>this is my
name;</my_root_tag>

Instead of the first one (the one that you can read "normally"). And not to
mention the characters for all the "special" Spanish letters that will appear
when more tags are present.
What can be wrong? Is it me or they ? The one responsible for receiving or
sending the context is such way. I don't know how they generate the xml
document, whether it's stored on a database or loaded from a physical file.
These guys say that I'm not applying the "right encoding" to the data that
they're sending; but fail to answer me which one they're using.

Please help.

This is my web methods code:

[WebMethod]
public string upload_your_data(string your_data)
{
StringReader srReaderXML;

try
{
//
// reading the xml doc
//
srReaderXML = new StringReader(your_data);
//
// loading the XML (check for a well-formed doc) and XSD
//
XmlTextReader xtrDocXML = new XmlTextReader(srReaderXML);
XmlTextReader xtrDocXSD = new XmlTextReader
(ConfigurationSettings.AppSettings["XSDPath"].ToString() +
ConfigurationSettings.AppSettings["XSDFileName"].ToString());
//
// loading the schema (XSD)
//
XmlSchema xsDocXSD = new XmlSchema();
xsDocXSD = XmlSchema.Read(xtrDocXSD,null);
XmlSchemaCollection xscSchemaColeccion = new XmlSchemaCollection();
xscSchemaColeccion.Add(xsDocXSD);
//
// validating the XML doc against the XSD
//
XmlValidatingReader xvrValidatorDocXML = new XmlValidatingReader
(xtrDocXML);
xvrValidatorDocXML.Schemas.Add(xscSchemaColeccion) ;
xvrValidatorDocXML.ValidationType = ValidationType.Schema;
while(xvrValidatorDocXML.Read()); // the exception is thrown here
xvrValidadorDocXML.Close();

return "this is right"
}
catch(Exception ex)
{
return "this is wrong + ex.Message;
}
}

Thank you !!
Cesar

Jan 27 '06 #1
2 2951
I think they may be sending you a null terminated string.
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Cesar" wrote:
Hello,

I've developed a .NET C# web service; which has one method named, let's say,
upload_your_data. This method has one parameter ( string your_data). The
value that this parameter will actually have is the content of a XML
document. This data will be processed and check for a well-formed xml
document and will be validated against a XSD. Before putting my code, let me
go on and explain the whole situation.

This web method is invoked by some guys outside my organization and they are
using java applications (jsp's … it seems to be).
I've tested my web method locally (intranet) from the test page (the one
with the "invoke" button) and works fine. Also, I have tested my web service
using a .NET Windows App which loads a XML file and invokes the web method to
upload the content of the file and works perfectly. Moreover I tested the web
service with this windows app from my home connected to the internet via my
ISP and invoking the web method directly from my company's web server. This
test was also completed successfully.
And, if this is not enough testing, I enabled the httpget and httppost
methods to enable the web method to be tested remotely using the test page.
I've done this with some of my friends.

However these guys from this other company, have a java application which
invokes my web method and it fails exactly when the XSD is performed. It
throws this error: The data at the root level is invalid. Line 1, position 1.

If, for example the content of the XML is simply:

<?xml version="1.0" encoding="UTF-8"?><my_root_tag>this is my
name</my_root_tag>

I receive exactly that string (I check the value of the web method's
parameter: your_data, which is a string variable) when testing the web method
with my testing apps. But when these guys invoke the method, the value that I
get from them is:

<?xml version="1.0" encoding="UTF-8"?><my_root_tag>this is my
name;</my_root_tag>

Instead of the first one (the one that you can read "normally"). And not to
mention the characters for all the "special" Spanish letters that will appear
when more tags are present.
What can be wrong? Is it me or they ? The one responsible for receiving or
sending the context is such way. I don't know how they generate the xml
document, whether it's stored on a database or loaded from a physical file.
These guys say that I'm not applying the "right encoding" to the data that
they're sending; but fail to answer me which one they're using.

Please help.

This is my web methods code:

[WebMethod]
public string upload_your_data(string your_data)
{
StringReader srReaderXML;

try
{
//
// reading the xml doc
//
srReaderXML = new StringReader(your_data);
//
// loading the XML (check for a well-formed doc) and XSD
//
XmlTextReader xtrDocXML = new XmlTextReader(srReaderXML);
XmlTextReader xtrDocXSD = new XmlTextReader
(ConfigurationSettings.AppSettings["XSDPath"].ToString() +
ConfigurationSettings.AppSettings["XSDFileName"].ToString());
//
// loading the schema (XSD)
//
XmlSchema xsDocXSD = new XmlSchema();
xsDocXSD = XmlSchema.Read(xtrDocXSD,null);
XmlSchemaCollection xscSchemaColeccion = new XmlSchemaCollection();
xscSchemaColeccion.Add(xsDocXSD);
//
// validating the XML doc against the XSD
//
XmlValidatingReader xvrValidatorDocXML = new XmlValidatingReader
(xtrDocXML);
xvrValidatorDocXML.Schemas.Add(xscSchemaColeccion) ;
xvrValidatorDocXML.ValidationType = ValidationType.Schema;
while(xvrValidatorDocXML.Read()); // the exception is thrown here
xvrValidadorDocXML.Close();

return "this is right"
}
catch(Exception ex)
{
return "this is wrong + ex.Message;
}
}

Thank you !!
Cesar

Jan 29 '06 #2
Hi Dale,

Sorry, event the post was "displayed right".
What I received from them (those guys) are those coded characters that were
used in the early days of the internet. For instance:
Instead of getting the < symbol I receive "& l t;" (without the blank
spaces), instead of getting the > symbol I receive "& g t;"
So what I receive from them is something like (without the blank spaces):

?& l t;xml version=& quot;1.0& quot; encoding=& quot;UTF-8& quot;?& g t& l
t;my_root_tag& g t;this is my name;& g t& l t;/my_root_tag& g t;

Cesar

"Dale" wrote:
I think they may be sending you a null terminated string.
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Cesar" wrote:
Hello,

I've developed a .NET C# web service; which has one method named, let's say,
upload_your_data. This method has one parameter ( string your_data). The
value that this parameter will actually have is the content of a XML
document. This data will be processed and check for a well-formed xml
document and will be validated against a XSD. Before putting my code, let me
go on and explain the whole situation.

This web method is invoked by some guys outside my organization and they are
using java applications (jsp's … it seems to be).
I've tested my web method locally (intranet) from the test page (the one
with the "invoke" button) and works fine. Also, I have tested my web service
using a .NET Windows App which loads a XML file and invokes the web method to
upload the content of the file and works perfectly. Moreover I tested the web
service with this windows app from my home connected to the internet via my
ISP and invoking the web method directly from my company's web server. This
test was also completed successfully.
And, if this is not enough testing, I enabled the httpget and httppost
methods to enable the web method to be tested remotely using the test page.
I've done this with some of my friends.

However these guys from this other company, have a java application which
invokes my web method and it fails exactly when the XSD is performed. It
throws this error: The data at the root level is invalid. Line 1, position 1.

If, for example the content of the XML is simply:

<?xml version="1.0" encoding="UTF-8"?><my_root_tag>this is my
name</my_root_tag>

I receive exactly that string (I check the value of the web method's
parameter: your_data, which is a string variable) when testing the web method
with my testing apps. But when these guys invoke the method, the value that I
get from them is:

<?xml version="1.0" encoding="UTF-8"?><my_root_tag>this is my
name;</my_root_tag>

Instead of the first one (the one that you can read "normally"). And not to
mention the characters for all the "special" Spanish letters that will appear
when more tags are present.
What can be wrong? Is it me or they ? The one responsible for receiving or
sending the context is such way. I don't know how they generate the xml
document, whether it's stored on a database or loaded from a physical file.
These guys say that I'm not applying the "right encoding" to the data that
they're sending; but fail to answer me which one they're using.

Please help.

This is my web methods code:

[WebMethod]
public string upload_your_data(string your_data)
{
StringReader srReaderXML;

try
{
//
// reading the xml doc
//
srReaderXML = new StringReader(your_data);
//
// loading the XML (check for a well-formed doc) and XSD
//
XmlTextReader xtrDocXML = new XmlTextReader(srReaderXML);
XmlTextReader xtrDocXSD = new XmlTextReader
(ConfigurationSettings.AppSettings["XSDPath"].ToString() +
ConfigurationSettings.AppSettings["XSDFileName"].ToString());
//
// loading the schema (XSD)
//
XmlSchema xsDocXSD = new XmlSchema();
xsDocXSD = XmlSchema.Read(xtrDocXSD,null);
XmlSchemaCollection xscSchemaColeccion = new XmlSchemaCollection();
xscSchemaColeccion.Add(xsDocXSD);
//
// validating the XML doc against the XSD
//
XmlValidatingReader xvrValidatorDocXML = new XmlValidatingReader
(xtrDocXML);
xvrValidatorDocXML.Schemas.Add(xscSchemaColeccion) ;
xvrValidatorDocXML.ValidationType = ValidationType.Schema;
while(xvrValidatorDocXML.Read()); // the exception is thrown here
xvrValidadorDocXML.Close();

return "this is right"
}
catch(Exception ex)
{
return "this is wrong + ex.Message;
}
}

Thank you !!
Cesar

Jan 29 '06 #3

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

Similar topics

6
by: Iain | last post by:
I've got a system which takes an XML file, translates it into an update gram and then loads it into my database with SQLXML3 (all in dot net). But it's fragile. And the SQLXML 3 error reporting...
2
by: Joakim Olesen | last post by:
Hello When validating xml against a schema, the most frequent error I get is something like "The 'FOO' attribute has an invalid value according to its data type. An error occurred at , (25,...
5
by: pmud | last post by:
Hi, I am using a compare validator in asp.net application(c# code). This is used for comparing a value enterd by the user against the primary key in the SQL database. IF the VALUE ENTERED BY THE...
0
by: Mark | last post by:
I have a very strange problem that is driving me nuts. My application is using the webclient object to send data to a webserver running on a unix box. We use 2 different environments, 1 for...
1
by: Cesar | last post by:
Hello, I've developed a .NET C# web service; which has one method named, let's say, upload_your_data. This method has one parameter ( string your_data). The value that this parameter will...
1
by: Chris Lieb | last post by:
I have an XML Schema file that I know is correct becuase I currently use it in a VB6 program to validate XML documents. Also, if I load an XML file into VS2005 that is not valid against this...
3
by: Martin Eckart | last post by:
Hi guys, I have an XML Schema and I am validation many XML files against the schema. If successful, the files get transferred to another location. If not, then I would like to add an error tag...
5
by: ioni | last post by:
Good day, fellows! I have a strange problem at my site there is a flash strip, that loads data dynamically. It works fine (grabs data from the remote server and presents it), however in IE7...
7
by: =?Utf-8?B?Q29kZVJhem9y?= | last post by:
I wrote a method to validate and xml file against a schema. If the file does not conform to the schema, it throws an error. It works fine except for one curious thing. If I try to validate an...
4
by: agda.karlberg | last post by:
Hello, I need to remove the DTD reference from an xml document, the reason for this is that we want to validate against a schema instead (which we have locally). It takes up to a minute to fetch...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.