0
Staff bumped into above error while trying to create a webservice
and I’m having a hard time interpreting and treating him.
Detailing what I did:
Within a project InpartSaude.WebApi.Api
in one of my controllers
I have a method to obtain data from a user, when accessing through the browser:
http://localhost:24083/InpartSaudeApi/Usuario/ObterUsuario?login=kk&senha=kkk
I managed to return a XML
with the data as expected.
Then in the same project I created a WebService
"Webserviceusuario.asmx", copied the controller method for this [WebMethod]
and tried to run it in order to test my webservice
but I stumbled upon the title error. I’m learning kind of in practice and I couldn’t understand the error nor a way to correct it.
Below is the method:
public class WebServiceUsuario : System.Web.Services.WebService
{
[WebMethod]
public List<Data.Usuario> ObterUsuario(string login, string senha)
{
using (InpartSaudeEntities db = new InpartSaudeEntities()) {
return (from x in db.Usuario
from y in db.UsuarioDistribuidor.Where(a => a.idUsuario == x.idUsuario).DefaultIfEmpty()
from z in db.Distribuidor.Where(b => b.idDistribuidor == y.idDistribuidor).DefaultIfEmpty()
where x.nmLogin == login
&& x.nmSenha == senha
&& x.blAtivo == 1
&& x.blBloqueado == false
select x
).ToList().Select(x => new Usuario {
idUsuario = x.idUsuario,
cdTipoUsuario = x.cdTipoUsuario,
idGrupoCliente = x.idGrupoCliente,
idPerfil = x.idPerfil,
nmEmail = x.nmEmail,
nmLogin = x.nmLogin,
nmUsuario = x.nmUsuario,
idDistribuidor = x.idDistribuidor
}
).ToList();
}
}
}
My class Data.Usuario
comes from edmx
, that is, it was automatically generated by EF
.
Post the definition of
Data.Usuario
, please.– Jéf Bueno
Try to hit a
[Serializable]
in class.– Francisco
You haven’t solved it yet?
– Jéf Bueno
I’m researching here to see what can be, I tried the Serializable but he says it is not possible to use with this type of data, maybe I should return in another format
– Caique Romero