Solved

Getting A Datatable name error web services

Posted on 2009-07-25
4,767 Views
Last Modified: 2013-12-17
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

0
Question by:npl77
    2 Comments
     
    LVL 15

    Expert Comment

    by:jinal

    [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

    0
     
    LVL 15

    Accepted Solution

    by:
    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;
    
        }
    

    Open in new window

    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    In this video tutorial I show you the main steps to install and configure  a VMware ESXi6.0 server. The video has my comments as text on the screen and you can pause anytime when needed. Hope this will be helpful. Verify that your hardware and BIO…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    680 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    28 Experts available now in Live!

    Get 1:1 Help Now