An error occurred while receiving the HTTP response to http://localhost:8088/EmployeesService. 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.
我在使用WCF的时候 服务器端有个方法使用linq 查询返回ObservableCollection<Employee> 类型。
客户端在调用这个方法的时候就出现了如上的错误信息。
我在调试的时候发现,服务器端返回其他类型的方法都没有问题,只有返回这个ObservableCollection<Employee> 类型出错。
下面是我的代码:
客户端调用:
using (EmployeesServiceClient proxy = new EmployeesServiceClient("BasicHttpBinding_IEmployeesService"))
{
//System.Windows.MessageBox.Show(proxy.test());
AllEmployees=proxy.GetAllEmployees();
proxy.Close();
//RaisePropertyChanged("AllEmployees");
}
Contract 类:
public interface IEmployeesService
{
[OperationContract]
ObservableCollection<Employees> GetAllEmployees();
// TODO: Add your service operations here
[OperationContract]
string test();
}
ContractService 类:
public class EmployeesService : IEmployeesService
{
WPFBusiness.BEmployees be = new BEmployees();
public ObservableCollection<Employees> GetAllEmployees()
{
return be.GetAllEmployees();
}
}
endpoint:
<endpoint address="" binding="basicHttpBinding" contract="WcfContract.IEmployeesService"/>
1.Employees类属性中是否有加[DataMember]契约?
2.服务引用中的配置是否将集合类型配置成了ObservableCollection类型?