Hello,
I've developed a .NET C# web service; which has one method named, let's say,
upload_your_dat a. 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_ta g>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_ta g>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_dat a(string your_data)
{
StringReader srReaderXML;
try
{
//
// reading the xml doc
//
srReaderXML = new StringReader(yo ur_data);
//
// loading the XML (check for a well-formed doc) and XSD
//
XmlTextReader xtrDocXML = new XmlTextReader(s rReaderXML);
XmlTextReader xtrDocXSD = new XmlTextReader
(ConfigurationS ettings.AppSett ings["XSDPath"].ToString() +
ConfigurationSe ttings.AppSetti ngs["XSDFileNam e"].ToString());
//
// loading the schema (XSD)
//
XmlSchema xsDocXSD = new XmlSchema();
xsDocXSD = XmlSchema.Read( xtrDocXSD,null) ;
XmlSchemaCollec tion xscSchemaColecc ion = new XmlSchemaCollec tion();
xscSchemaColecc ion.Add(xsDocXS D);
//
// validating the XML doc against the XSD
//
XmlValidatingRe ader xvrValidatorDoc XML = new XmlValidatingRe ader
(xtrDocXML);
xvrValidatorDoc XML.Schemas.Add (xscSchemaColec cion);
xvrValidatorDoc XML.ValidationT ype = ValidationType. Schema;
while(xvrValida torDocXML.Read( )); // the exception is thrown here
xvrValidadorDoc XML.Close();
return "this is right"
}
catch(Exception ex)
{
return "this is wrong + ex.Message;
}
}
Thank you !!
Cesar 2 2992
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_dat a. 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_ta g>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_ta g>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_dat a(string your_data) { StringReader srReaderXML;
try { // // reading the xml doc // srReaderXML = new StringReader(yo ur_data); // // loading the XML (check for a well-formed doc) and XSD // XmlTextReader xtrDocXML = new XmlTextReader(s rReaderXML); XmlTextReader xtrDocXSD = new XmlTextReader (ConfigurationS ettings.AppSett ings["XSDPath"].ToString() + ConfigurationSe ttings.AppSetti ngs["XSDFileNam e"].ToString()); // // loading the schema (XSD) // XmlSchema xsDocXSD = new XmlSchema(); xsDocXSD = XmlSchema.Read( xtrDocXSD,null) ; XmlSchemaCollec tion xscSchemaColecc ion = new XmlSchemaCollec tion(); xscSchemaColecc ion.Add(xsDocXS D); // // validating the XML doc against the XSD // XmlValidatingRe ader xvrValidatorDoc XML = new XmlValidatingRe ader (xtrDocXML); xvrValidatorDoc XML.Schemas.Add (xscSchemaColec cion); xvrValidatorDoc XML.ValidationT ype = ValidationType. Schema; while(xvrValida torDocXML.Read( )); // the exception is thrown here xvrValidadorDoc XML.Close();
return "this is right" } catch(Exception ex) { return "this is wrong + ex.Message; } }
Thank you !! Cesar
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_dat a. 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_ta g>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_ta g>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_dat a(string your_data) { StringReader srReaderXML;
try { // // reading the xml doc // srReaderXML = new StringReader(yo ur_data); // // loading the XML (check for a well-formed doc) and XSD // XmlTextReader xtrDocXML = new XmlTextReader(s rReaderXML); XmlTextReader xtrDocXSD = new XmlTextReader (ConfigurationS ettings.AppSett ings["XSDPath"].ToString() + ConfigurationSe ttings.AppSetti ngs["XSDFileNam e"].ToString()); // // loading the schema (XSD) // XmlSchema xsDocXSD = new XmlSchema(); xsDocXSD = XmlSchema.Read( xtrDocXSD,null) ; XmlSchemaCollec tion xscSchemaColecc ion = new XmlSchemaCollec tion(); xscSchemaColecc ion.Add(xsDocXS D); // // validating the XML doc against the XSD // XmlValidatingRe ader xvrValidatorDoc XML = new XmlValidatingRe ader (xtrDocXML); xvrValidatorDoc XML.Schemas.Add (xscSchemaColec cion); xvrValidatorDoc XML.ValidationT ype = ValidationType. Schema; while(xvrValida torDocXML.Read( )); // the exception is thrown here xvrValidadorDoc XML.Close();
return "this is right" } catch(Exception ex) { return "this is wrong + ex.Message; } }
Thank you !! Cesar This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 is not absolutely
wonderful.
So what I want to do is to validate it before I upload it.
When I try and do this I get MILLIONS of errors (well...
|
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, 913)". That error message is not very user
friendly, so I'd like to extract the data in the failing node along with its
parent node data, and show that...
|
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 USER EXISTS IN THE DB , then THE ERROR
MESSAGE OF THE COMPARE VALIDATOR SHOULD BE DISPLAYED.
For this, I used the reference artiicle...
|
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 development and 1
for a staging environment. I'm using an invalid servlet name in the
url deliberately in order to test my logic for basic communication...
|
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 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....
| |
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 schema, I get XML
errors (blue squigglies) in a few places, which indicates to me that I
should get validation errors while validating through code.
...
|
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 right after the corresponding XmlNode (in the
next line) specifying the error message.
I am currently validating using an XMLReader with...
|
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 and its clones I encounter a strange problem where I
can hear clicking sound non-stop (like the page is being reloaded non-
stop), whereas the page...
|
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 XDocument (containing schema xml) against a schema
url, it validates successfully..... Has anyone ever seen this before or know
why it does this.
...
|
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 all documents
referred to in the DTD, and as we have no use for them I want to
remove the reference.
I'm using XmlReaderSettings to pass in the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |