Solved

Getting A Datatable name error web services

Posted on 2009-07-25
4,795 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.

    Featured Post

    Cisco Complete Network Certification Training

    If you’re an IT engineer or technician, it's time you take your career to the next level. This elite training bundle is brimming with all of the information you need to learn to sit for Cisco CNNA, CCNP, and CCENT certification exams.

    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    Want to pick and choose which updates you receive? Feel free to check out this quick video on how to manage your email notifications.
    Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    913 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

    12 Experts available now in Live!

    Get 1:1 Help Now