Talk to Webmaster Tony John
|
Forums » .NET » Webservices »
Posted Date: 07 Sep 2010 Posted By:: mox shah Member Level: Gold Member Rank: 645 Points: 1
Responses:
1
|
Hey Friends, I have made one WebServices (For My Chat Application) to send and Receive Messages.Its working fine with receive message method,But gives an exception when any one send message
This is the exception
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: Cannot serialize the DataTable. DataTable name is not set. at System.Data.DataTable.WriteXmlSchema(XmlWriter writer, Boolean writeHierarchy) at System.Data.DataTable.System.Xml.Serialization.IXmlSerializable.WriteXml(XmlWriter writer) at System.Xml.Serialization.XmlSerializationWriter.WriteSerializable(IXmlSerializable serializable, String name, String ns, Boolean isNullable, Boolean wrapped) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write3_AddMessageResponse(Object[] p) at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer5.Serialize(Object objectToSerialize, XmlSerializationWriter writer) at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id) --- End of inner exception stack trace --- at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id) at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle) at System.Web.Services.Protocols.SoapServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream) at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues) at System.Web.Services.Protocols.WebServiceHandler.Invoke() --- End of inner exception stack trace ---
And here is my send message code...
[WebMethod] public DataTable AddMessage(string sDealer, string sUser, string sMsg, DataTable oDt) { if (oDt == null) { oDt = new DataTable(); oDt.Columns.Add(new DataColumn("UserName", typeof(string))); oDt.Columns.Add(new DataColumn("Message", typeof(string))); oDt.Columns.Add(new DataColumn("Date", typeof(string))); } DataRow oDr = oDt.NewRow(); oDr["UserName"] = sUser; oDr["Message"] = sMsg; oDr["Date"] = DateTime.Now.ToString(); oDt.Rows.Add(oDr);
string sTime = DateTime.Now.ToString(); string sAddText = sDealer + "~" + sUser + "~" + sMsg + "~" + sTime; return oDt; }
Whats the error??
Thanks And Regards MoKsHShaH
|
Responses
|
#547675 Author: Danasegarane.A Member Level: Gold Member Rank: 65 Date: 07/Sep/2010 Rating:  Points: 2 | You are checking the datatable is null, if null, add column. Check the column existance,if the datatable is not null for the function
Thanks & Regards, Danasegarane Arunachalam
http://www.techreceipe.com/
|
|
| Post Reply |
|
|
|
 | | This thread is locked for new responses. Please post your comments and questions as a separate thread. If required, refer to the URL of this page in your new post. |
|
|
|
|
 Follow us on Twitter: https://twitter.com/dotnetspider
|
Active MembersTodayLast 7 Daysmore...
|