Link to home
Start Free TrialLog in
Avatar of npl77
npl77

asked on

Getting A Datatable name error web services

Can someone help me debug this exception, I have set the "name" of the datatable in my web service(shown below) but am still getting this error:

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.Write4_GetNicksDataResponse(Object[] p)
   at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer1.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 ---
[WebMethod(Description="This method is used to returns BigM News. Username and Password MUST be provided.")]
    [SoapHeader("CustomSoapHeader")]
    public DataTable GetNicksData()
    {
         // Test to see if the proper credentials were passed in.
 
        ServiceAuthHeaderValidation.Validate(CustomSoapHeader);
             
        DataTable dt = new DataTable("myData");
       dt=BMHAccess.GetNews();
        return dt;
    }

Open in new window

Avatar of jinal
jinal
Flag of India image


[WebMethod(Description="This method is used to returns BigM News. Username and Password MUST be provided.")]
    [SoapHeader("CustomSoapHeader")]
    public DataTable GetNicksData()
    {
         // Test to see if the proper credentials were passed in.
 
        ServiceAuthHeaderValidation.Validate(CustomSoapHeader);
             
        DataTable dt = new DataTable("myData");
        dt=BMHAccess.GetNews();
        dt.TableName = "Test";
        return dt;
    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of jinal
jinal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial