Web Service error, but works fine with same code client-side. SOAP response issue?

Hey there,

I've been tasked with removing all database code from the client software, and moving it into a web service so that there's a single central codebase that handles all database calls (and the client software just talks to it).

Anyway, one of my web methods queries the database and returns a DataTable object to the client that called it.

I've tested the same code on the client side, where it worked fine. As soon as the exact same code is run by making a call to the web service – you guessed it, error.

Here's the exception details:

 There is an error in XML document (1, 26444). at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle) at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at EAST.AtspecDataAccess.Service.ReadData(String sqlCommand) in D:Visual Studio ProjectsEASTWeb ReferencesAtspecDataAccessReference.cs:line 178 at EAST.Planning.FormThanxLetter(String sCliNum, String sLocNum, String sFName, String sLName, String sUserID, String sDueDate, String sAmount, String sClient, String sLocation, String sStreet, String sSuburb, String sTown, String sLStreet, String sLSuburb, String sLTown, Boolean beMail) in D:Visual Studio ProjectsEASTPlanning.aspx.cs:line 1551 Target Site: System.Object Deserialize(System.Xml.XmlReader, System.String, System.Xml.Serialization.XmlDeserializationEvents) '', hexadecimal value 0x01, is an invalid character. Line 1, position 26444. System.Xml at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args) at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res, String[] args) at System.Xml.XmlTextReaderImpl.ParseNumericCharRefInline(Int32 startPos, Boolean expand, StringBuilder internalSubsetBuilder, Int32& charCount, EntityType& entityType) at System.Xml.XmlTextReaderImpl.ParseCharRefInline(Int32 startPos, Int32& charCount, EntityType& entityType) at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars) at System.Xml.XmlTextReaderImpl.ParseText() at System.Xml.XmlTextReaderImpl.ParseElementContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlTextReader.Read() at System.Data.DataTextReader.Read() at System.Data.XmlDataLoader.LoadColumn(DataColumn column, Object[] foundColumns) at System.Data.XmlDataLoader.LoadTable(DataTable table, Boolean isNested) at System.Data.XmlDataLoader.LoadData(XmlReader reader) at System.Data.DataTable.ReadXmlDiffgram(XmlReader reader) at System.Data.DataTable.ReadXml(XmlReader reader, XmlReadMode mode, Boolean denyResolving) at System.Data.DataTable.ReadXmlSerializable(XmlReader reader) at System.Data.DataTable.System.Xml.Serialization.IXmlSerializable.ReadXml(XmlReader reader) at System.Xml.Serialization.XmlSerializationReader.ReadSerializable(IXmlSerializable serializable, Boolean wrappedAny) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderService.Read7_ReadData_DefaultResponse() at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer15.Deserialize(XmlSerializationReader reader) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) Void Throw(System.Exception) 

At this stage I'm thinking that when the DataTable is created, there's a space character or something like that which affects the structure of the returned XML.

Could anyone help me out? This is my first time dealing with Web Services, so I'd very much appreciate being bumped on the right track.

Please let me know if more info is needed, as I'm not sure how contextual the issue is.

by rhonage via /r/csharp

Leave a Reply