Getting A Datatable name error web services

    Question by:
    On

    Topics:

    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;
        }
    
                                    
    1:
    2:
    3:
    4:
    5:
    6:
    7:
    8:
    9:
    10:
    11:
    12:
    

    Select allOpen in new window

    Good Question?
    0
     

    ?

    The member who asked this question verified this comment provided the solution that solved their problem.

    Accepted Solution on 2009-07-25 at 08:39:24ID: 24941979

    It should work now.

    [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 = "myData";
            return dt;
        }
    
                                            
    1:
    2:
    3:
    4:
    5:
    6:
    7:
    8:
    9:
    10:
    11:
    12:
    13:
    

    Select allOpen in new window

    Top Expert Contributor

    Essential articles and videos from the Experts

    More valuable questions with Expert answers

    201601-LO-Qu-076

    Extend your technology team with the Experts Exchange community.

    — trusted by —

    Who answers my questions?Our community has technology experts around the world.

    käµfm³d   👽

    9

    Articles

    Expert in:

    • .NET Programming
    • C#
    • Visual Basic.NET
    • ASP.NET
    • Regular Expressions

    Jacques Bourgeois (James Burger)

    2

    Articles

    Expert in:

    • .NET Programming
    • Visual Basic.NET
    • C#
    • MS Development
    • ASP.NET

    Karrtik Iyer

    Expert in:

    • .NET Programming
    • C#
    • Visual Basic.NET
    • ASP.NET
    • C++

    Fernando Soto

    Expert in:

    • .NET Programming
    • Visual Basic.NET
    • C#
    • ASP.NET
    • Editors IDEs

    Alexandre Simões

    6

    Articles

    Expert in:

    • .NET Programming
    • C#
    • JavaScript
    • Visual Basic.NET
    • ASP.NET

    Miguel Oz

    2

    Articles

    Expert in:

    • .NET Programming
    • ASP.NET
    • C#
    • Visual Basic.NET
    • MS Development

    Éric Moreau

    2

    Articles

    Expert in:

    • .NET Programming
    • Visual Basic.NET
    • C#
    • Visual Basic Classic
    • ASP.NET

    Abhigyan Srivastava

    Expert in:

    • .NET Programming
    • ASP.NET

    jorge_toriz

    Expert in:

    • ASP.NET
    • .NET Programming
    • C#
    • MS SQL Server
    • MS SQL Server 2005

    RELATED TOPICS view all topics

    1. ASP.NET
      (122,068)
    2. C#
      (90,372)
    3. Visual Basic.NET
      (91,422)
    4. MS Development
      (48,689)
    5. Editors IDEs
      (25,093)
    6. Visual Basic Classic
      (162,808)
    7. MS SQL Server
      (154,632)
    8. MS SQL Server 2005
      (71,583)
    9. Programming
      (51,612)
    10. JavaScript
      (117,311)