Solved

Getting A Datatable name error web services

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

Good Question?
0
Question by:npl77
    249 Solutions
    Best Solution byjinal
    It should work now.
    2 Comments
     
    249 Solutions

    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

    Good Comment?
    0
     
    249 Solutions

    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

    Good Solution?
    0

    Add a Comment

    Join our community to follow up on this question and 4 million more solutions.

    Join & Write a Comment

    Featured Post

    Course: JavaScript Coding - Massive 12-Part Bundle

    Regardless of your programming skill level, you'll go from basics to advanced concepts in a vast array of JavaScript subjects including Sammy.js, Agility.js, Ember.js, Node.js, jQuery, AJAX, Extjs, AngularJS, Knockout.js, and JSON.

    While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
    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:…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

    780 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

    23 Experts available now in Live!

    Get 1:1 Help Now