1

I created a web service (ASP.NET Web Service Application ,.NET framework 3.5) that accesses the database, retrieves the data and returns it to client as DataTable type.

When I calling this web service from a client app I get the error message "There is an error in XML document (1, 36276)" with inner exception "Unexpected end of file while parsing Name has occurred. Line 1, position 36276."

I have tried to reduce the amount of data returned by the query (SELECT TOP 1) - error disappeared. But I need all my data :) (118 rows with 30 columns)

I guess that the problem is that the web service response string does not fit the default serialization buffer (probably 4kb), and therefore there is "Unexpected end of file".

How can I increase the length (or maybe type) of web service serialization buffer?

Web service code:

[WebMethod]
public DataTable GetTargetAchievement()
{
    var dt = new DataTable("TableName");

    using (var conn = new SqlConnection(GetConnectionString()))
    {
        using (var da = new SqlDataAdapter("select * from [Table] ORDER BY 1,3,2; ", conn))
        {
            da.Fill(dt);
        }
    }

    return dt;
}

Client (WPF) code:

private void btnCallService_Click(object sender, RoutedEventArgs e)
{
    TAA.AuditService service = new TAA.AuditService();
    var dt = service.GetTargetAchievement();

    lbxList.ItemsSource = dt.DefaultView;
}
Andrey Morozov
  • 7,839
  • 5
  • 53
  • 75
  • @Anurag, thanks for the link, but in my case, I do not use WCF. My project is "old style" ASP.NET Web Service Application. – Andrey Morozov Jan 31 '12 at 18:28
  • I've seen this issue before when the data coming across the web service has special characters in it that can mess up the XML serialization. – MrDustpan Apr 04 '12 at 17:27

0 Answers0