Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello ...
i have a wcf service from which i am returning a data table . my code is ...
C#
[ServiceContract]
public interface IMyWCFService
{	
    [OperationContract]
    Student StudentRecord();
}

[DataContract]
public class Student
{
    [DataMember]
    public DataTable StudentTable
    {
        get;
        set;
    }
}

and the other file code is ...
C#
public Student StudentRecord()
{
    Student st = new Student();
    DataTable dt = new DataTable();
    SqlConnection con = new SqlConnection("data source=ggsys03 ; initial catalog=Test ; integrated security=true");

    SqlDataAdapter da = new SqlDataAdapter("select * from studentInfo", con);
    da.Fill(dt);
    st.StudentTable = dt;
    return st;

}

when i using this it gives error ...

C#
"An exception of type 'System.ServiceModel.CommunicationException' occurred in mscorlib.dll but was not handled in user code

Additional information: An error occurred while receiving the HTTP response to http://localhost:49314/MyWCFService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details."

how to solve out this problem ...
Posted
v2
Comments
Raajkumar.b 5-Mar-14 4:19am    
hi,
may be the problem is in web.config file
check this link once
http://realtimescenarios.blogspot.in/2013/05/wcf-communicationexception-this-could.html
Modify the web.config to allow large data.

Give a name to a DataTable Like new DataTable("Students");

-KR
 
Share this answer
 
Comments
GDdixit 5-Mar-14 2:49am    
ok , i will try this but the error is same yet ..
Krunal Rohit 5-Mar-14 8:56am    
Okay tell me, why are you using DataTable here ? I mean if you've created DataContract, what's the use of it ?

-KR
use like this

first increase your bufferrecive size

verify this

https://stackoverflow.com/questions/5337412/buffer-size-in-wcf-service[^]

Still it happen do like this, i hope it ill work

CSS
[ServiceContract]
public interface IMyWCFService
{
    [OperationContract]
    DataTable StudentRecord();
}

//[DataContract]
//public class Student
//{
    //[DataMember]
    //public DataTable StudentTable
    //{
     //   get;
       // set;
    //}
//}




public DataTable StudentRecord()
{
//Student st = new Student();
DataTable dt = new DataTable();
SqlConnection con = new SqlConnection("data source=ggsys03 ; initial catalog=Test ; integrated security=true");

SqlDataAdapter da = new SqlDataAdapter("select * from studentInfo", con);
da.Fill(dt);
//st.StudentTable = dt;
return dt;

}
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900