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
0
Cesar (59)
1/27/2006 12:00:02 AM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
401 Views

Similar Articles

[PageSpeed] 55

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

"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
0
Cesar (59)
1/29/2006 8:31:26 AM
Reply:

Similar Artilces:

Error in mail merge after changing zip code field codes
Hello I'm getting the messages "Invalid merge field" and "Error: Merge field was not found in header record data source" after changing the field codes by inputting five 0's in the zip code merge field. I also chose the 'excel spreadsheet via DDE' in confirm data source list. Thanks in advance for your help Wes ...

xml beginners question
Hi I have an xml file that contains the following data at the bottom of this email.. I want to step through each getting the date and the pick qty. In my code here I only every get one, the first value back.. Is my vb code wrong, or my xml file not proper ? m_picklist = m_xmld.SelectNodes("/LogData/Picks") For Each m_node In m_picklist Dim pDate = m_node.ChildNodes.Item(0).InnerText Dim pCount = m_node.ChildNodes.Item(1).InnerText Next ................ (xml extract) <LogData> <Serial>A-01-03-01</Serial> <SQLV...

Ole Automation Error Sending eMail via Outlook 2007
Hello Ng, Hope, this is the right forum. We are using Outlook Automation to send email out of a database application (Gupta). Everything worked fine so far, but since installation of Outlook 2007 Update KB 969907 we get the error message: "Ole Automation Runtime Error 800706ba, Invocation of Create Item" A debug run shows that this error occurs on invocation of function OutlookApp.CreateItem(Outlook_OlItemType_olMailItem, OutlookMail ). Has anyone an idea to get rid of this? THANKS! regards Uwe ...

Fax OCR error
Hi all, I am getting the following error when faxes arrive to my CRM queue. I guess the CRM can't complete OCR on the fax. Any specific software needs to be installed on the server to get this wortking? Thanks in advance, ________________________________________________ Event Type: Error Event Source: MSCRMFaxRouterService Event Category: None Event ID: 0 Date: 2007.05.10 Time: 13:20:56 User: N/A Computer: JUPITER Description: System.ApplicationException: OCR of the current document image failed. at Crm.Tools.FaxAnalysis.FaxAnalysisModule.AnalyzeFax(String FaxImageFile, IFaxRecip...

Workflow error 11-27-07
Hi We have created a workflow that automatically generates a sequential number for an Order, once it has been converted from a Quote. This workflow can work fine for days on end, and then suddenly fails with 2 or 3 Orders in a row displaying the error message in the workflow monitor of 80044151. Having searched for this error, it seems to point to installing Update Rollup 1. This has already been done, along with Rollup 2. We are using SQL Server 2000. Can anyone help with this issue – we have run out of things to try. -- Many Thanks Jan_s ...

Xml and unicode values with &#x...
Hello! I like to use the XmlTextWriter to write some SVG files. But in some cases, I need the '&' as '&' and not as &amp;. Example: <glyph unicode=3D"&#x4c;"/> Some code-snippet: XmlDocument ^ doc =3D gcnew XmlDocument(); .... XmlAttribute ^ a =3D doc->CreateAttribute("unicode"); a1->Value =3D ??? - what to write here? ... Stream ^ fs =3D gcnew FileStream(filename, FileMode::Create); ... XmlWriter^ writer =3D gcnew XmlTextWriter(fs, gcnew UTF8Encoding); = How can I force to write the att...

Importing XML into Excel
Does anyone know what's required to update the MS Excel 2000 software to allow me to open XML files? I know Excel 2002 has this feature. ...

Error 2140
Dear folks, I get an error 2140 when I=B4m trying to restart the=20 Exchange (5.5) Event Services. Error 2140: An internal Windows NT error ocurred. The HWprofile is enable and with Admin rights. Any suggestions? Thanks in advance! What events are you seeing in yoru Event log? Could either of these articles help? 285021 XADM: Exchange Event Service Does Not Start with Error 2140 http://support.microsoft.com/?id=285021 190993 XADM: Events Service Fails to Start with MAPI 0x80040107 http://support.microsoft.com/?id=190993 -- Hope that helps. ------------------------- Jaclynn Hiranaka ...

excel 2003 error>> compile error in hidden module: ThisWorkbook
Hi, I created this worksheet in Office XP. Now I have a new compute with WindowsXP pro and Office 2003. This worksheet opens fine on othe machines but on mine I get "compile error in hidden module: ThisWorkbook" When I look at it in VBA and run it , it will stop on this line. Else response = MsgBox("This is my message to the user.", _ vbOKCancel) If response = vbOK Then What is different in Office 2003 to make it have an error now -- Message posted from http://www.ExcelForum.com Hi Clayton, > Hi, I created this worksheet in Office XP. Now I have a new computer ...

Error after updating contact form
Responsible for MSCRM tried to add a field to the contact form. Then we got error message and can't open the conact at all. Then the added field was removed, but there still error. Error message: MSCRM Platform Error Report: ----------------------------------------------------------- --------------------------------------------- Error: Invalid object name 'Contact'. Error Message: Invalid object name 'Contact'. Error Details: Details on this error have not been provided by the platform. Source File: Not available Line Number: Not available Stack Trace Info: a...

CRM Version 1.2 SQL Desktop Engine Error
I am trying to load the Microsoft CRM Sales for Outlook on a Windows XP Professional machine. When it trys to install the SQL Server 2000 Desktop Engine (SP3a) required component it gives me a error message of: "Setup has failed because of an error. Setup was unable to install Microsoft SQL Server 2000 Desktop Engine (SP3a). Install it separately and restart setup.exe." I downloaded the SQL Server 2000 Desktop Engine (SP3a) from the web. When I go to install the SQL SP3 I get a error message of: "The instance name is invalid." Has anyone seen or heard of this e...

CRM Mobile unexpected error in PDA
Hi All, i was attempting to install the CRM mobile for demo purposes. i can generate and install the package in PDA without any error, however when i tap the CMR Mobile in PDA I got the following error: CRMMobile.exe TypeLoadException CRMAppShell::Main+0x0 Has anyone encounter this error? The CA was generate using the SelfSSL. The install order in the Deployment Packages is set to the following order: 1. .Net Compact Framework 2. SQL CE 2.0 3. Certificate Settings 4. CRM Mobile Thanks. -- Regards, Ven...

xml to serialize a dataset
I created a dataset using the DataSet Designer - http://aspnet.4guysfromrolla.com/articles/020806-1.aspx My objective was to serialize the generated dataset. protected void Page_Load(object sender, EventArgs e) { SalesOrderHeaderTableAdapter Adapter = new SalesOrderHeaderTableAdapter(); AdventureWorks.SalesOrderHeaderDataTable Orders = Adapter.GetDataBy(new DateTime(2004, 7, 1)); this.GridView1.DataSource = Orders; this.GridView1.DataBind(); /////////////////////////////////////////////////////////////////////////////// ...

coprocess ERROR
they know something of the error ' coprocess' greetings, Richard Padilla ...

Strange OWA problem
I have a user that is receiving two identical navigation panes. She is using Internet Explorer. The server is Windows 2003, and Exchange 2003. I recently installed SSL, and url redirection if that could possibly make a difference. Does anyone know why this happen, and how to fix it? They are right beside each other on the right side of the windows. Thanks C Emmons "C Emmons" <CEmmons@discussions.microsoft.com> wrote in message news:7B517C01-1044-45A7-8AFB-FE1D3D104FDE@microsoft.com... > I have a user that is receiving two identical navigation panes. She is using > ...

Exchange error #3
I am getting the following event in my exchange server system event with the event ID# 55: The file system structure on the disk is corrupt and unusable. pls run the chkdsk utility on the volume E:. My backup is also failing.. Can someone help me to resolve this issue? Thanks, SV Sounds like you have a physical disk problem. The event you reference is not from Exchange but from the OS. -- Tyrone Cowart Microsoft PSS Please do not send email directly to this alias. This alias is for newsgroup purposes only. This posting is provided "AS IS" with no warranties, and confers ...

HELP-The XML passed to the platform is not well-formed xml.
Both my test system and my live system are experiencing this. I cannot import, export or customize anything. I know the entity (and relationships) that are causing the problem but I do not know how to reverse out of it. Can anyone help? Thanks Saira Ive had this problem on my vmware images before, and the only way i got around it was to restore. "Saira" wrote: > Both my test system and my live system are experiencing this. > I cannot import, export or customize anything. > I know the entity (and relationships) that are causing the problem but I do > not know how...

Error Occured While Checking Spelling
Error Occured While Checking Spelling in Outlook 2002 The error occured because of a slight technical disorder originating inside the Intel processor's memory chip. This can be remedied by removing the chip while the computer is still on. You must pry from the metal edge with a non-magnetic screwdriver and soak it in Clorox overnight. Hope this helps!! >-----Original Message----- >Error Occured While Checking Spelling in Outlook 2002 >. > >-----Original Message----- >Error Occured While Checking Spelling in Outlook 2002 >. >Tom, I'm having the same ...

Error Message #5.1.2 after Upgrading to Exchange 2003
I started seeing these error messages when sending email to employees after the upgrade. At the bottom of the error it lists the old server name. I've tried the reset the nickname and the automatic completion caches in Outlook fix but that didn't work. The only other error I could find like this had to do with newsgroups. The following recipient(s) could not be reached: ****, ****** on 6/13/2005 2:06 PM The message could not be delivered because the recipient's destination email system is unknown or invalid. Please check the address and try again, or contact your system...

Outlook client error 07-09-03
"An error has occurred. For more information, contact your system administrator." I get the above message on the Outlook client when trying to view any details of any lead, opportunity, account etc. I am able to see the lists of contacts and accounts on the grid window, but when i click to open them, a window pops up and the error message appears. I can go offline and online with no problems. On Tue, 08 Jul 2003 23:59:06 -0700, dodger wrote: > "An error has occurred. For more information, contact your system > administrator." > > I get the above message on ...

Error 40036 just happens
I have an application with a subform "issueList". It works well, but sometimes after having made changse to the code I get Run-time error '40036' Method'Parent' of object '_Form_issueList' failed when running this code: Private Sub Form_Current() Dim rs As Object Set rs = Me.Parent.Recordset.Clone rs.FindFirst "[IID] = " & Me.IID If Not rs.EOF Then Me.Parent.Bookmark = rs.Bookmark End Sub When I go back and recreate the changes in a backup I may very well be able to make them without any errors. To me it l...

Error sending large file... Will not allow me to delete from Outbox
Error sending large file... Will not allow me to delete from Outbox... ********************************************** Error Message Detail Sending and Receiving Reporting Error (0x8004060C): 'Unknown Error (0x8004060C' ********************************************** No tries to initiate a Resend whenever I boot program and cannot pull in new "received" messages due to send error... Any thoughts (please) on how I can delete this from the Outbox? I've tried the obvious options... Very perplexed.... Thanks VERY much.... ...

svchost.exe error #2
When sending email in Outlook 2002 I receive the following message: svchost.exe has generated errors and will be closed by windows. If I reboot the email will go until the next time I generate and email. Any suggestions!!! Thanks, Candace ...

linked spreadsheet errors
When some Excel users open certain shared files on a network file share, they get this error message when promted to update the Links: "Unable to open https://Xmail.COMPANY.com/DocumentsandSettings/USERNAME\Local Settings\Temporary Internet Files\OLK659\FILE.xls. The Internet site reports that the item you requested could not be found. (HTTP/1.1.404)" The links do not actually point to the listed temp folder, and ultimately they are open and use the file after the error is shown. I'm not sure why the file might attempt to update the links from a temp internet folder, or why ...

There was an error running rules. Not all messages were processed
I am running Outlook 2007 on Windows 7 64 Bit. I am having a problem with the rules. Every time I run the runs (either a new one just created or an existing one) I get the Message 'There was an error running rules. Not all messages were processed'. I have deleted and recreated all my rules but still get the error, any ideas?. Try starting Outlook with the /cleanrules switch. This will clean all the rules from the server and client, including possible hidden ones. Start-> type; outlook.exe /cleanrules (note the space in the command) -- Robert Sparnaaij [MVP-...