[英]Serialization error when calling WCF service
When I call the service I receive this error: 当我致电服务时,我收到此错误:
Element ListadoClientesResult from namespace tempuri.org cannot have child contents to be deserialized as an object.
来自名称空间tempuri.org的元素ListadoClientesResult不能将子内容反序列化为对象。 Please use XmlNode[] to deserialize this pattern of XML
请使用XmlNode []反序列化这种XML模式
The service code is: 服务代码为:
public List<Empleado> ListarEmpleados()
{
List<Empleado> returnList = new List<Empleado>();
var lista = from u in DB.tabEmpleado
select new
{
u.idEmpleado,
u.idUsuario,
u.Nombre,
u.Apellidos,
u.Telefono1
};
foreach (var e in lista)
{
Empleado empleado = new Empleado();
empleado.idEmpleado = e.idEmpleado;
empleado.idUsuario = e.idUsuario;
empleado.nombre = e.Nombre;
empleado.apellidos = e.Apellidos;
empleado.telefono1 = e.Telefono1;
returnList.Add(empleado);
}
return returnList;
}
And the class definition is this: 类的定义是这样的:
[DataContract]
public class Empleado {
private int _idEmpleado;
[DataMember(IsRequired = false)]
public int idEmpleado
{
get { return _idEmpleado; }
set { _idEmpleado = value; }
}
private int _idUsuario;
[DataMember(IsRequired = false)]
public int idUsuario
{
get { return _idUsuario; }
set { _idUsuario = value; }
}
private string _nombre;
[DataMember(IsRequired = false)]
public string nombre
{
get { return _nombre; }
set { _nombre = value; }
}
private string _apellidos;
[DataMember(IsRequired = false)]
public string apellidos
{
get { return _apellidos; }
set { _apellidos = value; }
}
private string _telefono1;
[DataMember(IsRequired = false)]
public string telefono1
{
get { return _telefono1; }
set { _telefono1 = value; }
}
}
Here is the ServiceContract 这是服务合同
namespace MetodosNegocio
{
[ServiceContract]
public interface IService
{
[OperationContract]
List<Empleado> ListadoClientes();
}
}
How can I solve this problem? 我怎么解决这个问题?
Thanks in advance. 提前致谢。
在您更新服务之前 ,不会应用对服务所做的任何更改,因此我对其进行了更新,并且该功能可以正常使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.