C
Chris Peacock
I've found similar postings on various newsgroups suggesting that
other people have encountered this problem, but none of the postings
have replies. I hope therefore that the following may be of help.
My application is an ASP.NET one which calls
System.Text.UTF8Encoding.GetString on a byte sequence, and then
subsequently (well, a little later) attempts to call a Web Service
method. The call to the Web Service method fails with the exception
"hexadecimal value 0x00, is an invalid character", stack trace:-
[XmlException: '', hexadecimal value 0x00, is an invalid character.
Line 6, position 223.]
System.Xml.XmlScanner.ScanHexEntity()
System.Xml.XmlTextReader.ParseBeginTagExpandCharEntities() +1036
System.Xml.XmlTextReader.Read() +216
System.Xml.XmlReader.ReadElementString()
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadSoapException(XmlReader
reader)
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean
asyncCall)
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
MyWeb.MyWebData.MyClass.MyFunction(MyDataClass& data, Byte[]
byteSomeData) in c:\inetpub\wwwroot\MyWeb\Web
References\MyWebData\Reference.vb:108
MyWeb.MyHttpHandler.ProcessRequest(HttpContext context) in
c:\inetpub\wwwroot\MyWeb\MyHttpHandler.vb:57
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously) +87
I traced the problem to the call to GetString:-
strResult = textEncoding.GetString (byteText)
....and fixed the problem by replacing this with code as follows:-
decoder = textEncoding.GetDecoder()
iBytesToDecode = decoder.GetCharCount(byteText, 0,
byteText.GetLength(0))
chars = Array.CreateInstance(GetType(Char), iBytesToDecode)
decoder.GetChars(byteText, 0, iBytesToDecode, chars, 0)
strResult = New String(chars)
I am using .NET framework version 1.1.4322.573 and ASP.NET version
1.1.4322.573.
Hopefully this may be of help to someone.
other people have encountered this problem, but none of the postings
have replies. I hope therefore that the following may be of help.
My application is an ASP.NET one which calls
System.Text.UTF8Encoding.GetString on a byte sequence, and then
subsequently (well, a little later) attempts to call a Web Service
method. The call to the Web Service method fails with the exception
"hexadecimal value 0x00, is an invalid character", stack trace:-
[XmlException: '', hexadecimal value 0x00, is an invalid character.
Line 6, position 223.]
System.Xml.XmlScanner.ScanHexEntity()
System.Xml.XmlTextReader.ParseBeginTagExpandCharEntities() +1036
System.Xml.XmlTextReader.Read() +216
System.Xml.XmlReader.ReadElementString()
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadSoapException(XmlReader
reader)
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean
asyncCall)
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
MyWeb.MyWebData.MyClass.MyFunction(MyDataClass& data, Byte[]
byteSomeData) in c:\inetpub\wwwroot\MyWeb\Web
References\MyWebData\Reference.vb:108
MyWeb.MyHttpHandler.ProcessRequest(HttpContext context) in
c:\inetpub\wwwroot\MyWeb\MyHttpHandler.vb:57
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously) +87
I traced the problem to the call to GetString:-
strResult = textEncoding.GetString (byteText)
....and fixed the problem by replacing this with code as follows:-
decoder = textEncoding.GetDecoder()
iBytesToDecode = decoder.GetCharCount(byteText, 0,
byteText.GetLength(0))
chars = Array.CreateInstance(GetType(Char), iBytesToDecode)
decoder.GetChars(byteText, 0, iBytesToDecode, chars, 0)
strResult = New String(chars)
I am using .NET framework version 1.1.4322.573 and ASP.NET version
1.1.4322.573.
Hopefully this may be of help to someone.