This is an unexpected token. The expected token is 'NAME'

G

Guest

Hi,

i posted this error message a couple of weeks ago:

has anyone come across this error before:

This is an unexpected token. The expected token is 'NAME'

I am getting it when trying to send an xml file across a web service layer.

The xml file is well formed, having been checked with XmlSpy. The size of
the file is roughly 119KB. I think it was written in MS Word and the HTML is
being sent through the web service layer as a property of a serializable
object.

Searching the web has given me lots of results but none have found a
solution. The error suggests to me that it is reading the xml and suddenly
stops, which means it cannot find a closing tag. Is there a size limit to
the amount of data that can be serialized/deserialized in one go?

Any help would be really appreciated.


Since then I have determined that a field in a data table was causing a
problem and once corrected the transaction worked properly. However, it has
happened again when working with different files and I need to get down to
the root cause.

This time, the error message was:

"The opening tag 'ParagraphOrder' did not match the closing tag 'ParagraphOr'.

ParagraphOrder is a field in the serializable object and has a simple
numeric value. What the error suggests is that the serialized XML is being
read, gets to the closing ParagraphOrder tag and stops reading halway through
it. Or, it is halfway through the serialization when it occurs.

The stacktrace is a follows:

System.Xml.XmlTextReader.ParseTag() +2328
System.Xml.XmlTextReader.ParseBeginTagExpandCharEntities() +1478
System.Xml.XmlTextReader.Read() +216
Microsoft.Web.Services2.Xml.XmlSkipDTDReader.Read()
System.Xml.XmlLoader.LoadCurrentNode() +612
System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) +49
System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean
preserveWhitespace) +102
System.Xml.XmlDocument.Load(XmlReader reader) +72
Microsoft.Web.Services2.SoapEnvelope.Load(Stream stream)
Microsoft.Web.Services2.OutputStream.Close()
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters) +162
Internal methods to pass the object to the web service layer go here.

Could there be something in the XmlTextReader that sets a maximum buffer
size? If so, why does it normally work with even bigger files?

This one has me well and truly stumped.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

cashdeskmac said:
Hi,

i posted this error message a couple of weeks ago:

has anyone come across this error before:

This is an unexpected token. The expected token is 'NAME'

I am getting it when trying to send an xml file across a web service
layer.

I have seen this error before, it happens when the XML is not well formed.
Do this, instead of processing directly the XML save it to a file and see
what r u getting.
 
R

rossum

Hi,

i posted this error message a couple of weeks ago:

has anyone come across this error before:

This is an unexpected token. The expected token is 'NAME'

I am getting it when trying to send an xml file across a web service layer.

The xml file is well formed, having been checked with XmlSpy. The size of
the file is roughly 119KB. I think it was written in MS Word and the HTML is
being sent through the web service layer as a property of a serializable
object.

Searching the web has given me lots of results but none have found a
solution. The error suggests to me that it is reading the xml and suddenly
stops, which means it cannot find a closing tag. Is there a size limit to
the amount of data that can be serialized/deserialized in one go?

Any help would be really appreciated.


Since then I have determined that a field in a data table was causing a
problem and once corrected the transaction worked properly. However, it has
happened again when working with different files and I need to get down to
the root cause.

This time, the error message was:

"The opening tag 'ParagraphOrder' did not match the closing tag 'ParagraphOr'.

ParagraphOrder is a field in the serializable object and has a simple
numeric value. What the error suggests is that the serialized XML is being
read, gets to the closing ParagraphOrder tag and stops reading halway through
it. Or, it is halfway through the serialization when it occurs.

The stacktrace is a follows:

System.Xml.XmlTextReader.ParseTag() +2328
System.Xml.XmlTextReader.ParseBeginTagExpandCharEntities() +1478
System.Xml.XmlTextReader.Read() +216
Microsoft.Web.Services2.Xml.XmlSkipDTDReader.Read()
System.Xml.XmlLoader.LoadCurrentNode() +612
System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) +49
System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean
preserveWhitespace) +102
System.Xml.XmlDocument.Load(XmlReader reader) +72
Microsoft.Web.Services2.SoapEnvelope.Load(Stream stream)
Microsoft.Web.Services2.OutputStream.Close()
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters) +162
Internal methods to pass the object to the web service layer go here.

Could there be something in the XmlTextReader that sets a maximum buffer
size? If so, why does it normally work with even bigger files?

This one has me well and truly stumped.
Does the XML have a terminating newline/CR? Some XML readers need one
to correctly read the last line of their input.

If it is not that, then try sending a minimal XML file, just a few
lines, to see if it reads that correctly. Then build up to the full
file, checking often to see which part has the problem.

rossum
 
G

Guest

Sorry, but I should have explained this a bit better.

What I have is a letter written in MS Word and I put the content (including
the html that Word creates) into a property of a serializable object. This
object is then sent through the web service layer where it falls over. The
content of the file validates when using XmlSpy and parses properly when the
text is shown on a web page. Once the content has been assigned to the
serializable object and a web service call is made, it falls over.

Other (bigger) files make the journey without a problem so I am at a loss to
explain this.
 
R

rossum

Sorry, but I should have explained this a bit better.

What I have is a letter written in MS Word and I put the content (including
the html that Word creates) into a property of a serializable object. This
object is then sent through the web service layer where it falls over. The
content of the file validates when using XmlSpy and parses properly when the
text is shown on a web page. Once the content has been assigned to the
serializable object and a web service call is made, it falls over.

Other (bigger) files make the journey without a problem so I am at a loss to
explain this.
You can still try versions of the file, even if you have to edit it by
hand in an XML editor. Cut out parts of the file and try the reduced
file until you find what is causing the problem.

rossum
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top