Personally I ran into the above error when trying to create a webservice
and I'm having difficulty interpreting and treating it.
Detailing what I did:
Within aInpartSaude.WebApi.Api
project in one of my controllers
I have a method to get data from a user, when accessed by the browser:
http://localhost:24083/InpartSaudeApi/Usuario/ObterUsuario?login=kk&senha=kkk
I was able to return a XML
with the data as expected.
Then in the same project I created a WebService
"WebServiceUsuario.asmx", I copied the controller method to this [WebMethod]
and tried to execute it in order to test my webservice
but I came across the title error . I am learning rather than in practice and could not understand the error and not a way to correct it.
The following is the method below:
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
.