G4ma 0 Posted November 13, 2020 Report Share Posted November 13, 2020 Olá, bom dia! Quando chamo o serviço WCF no lado do cliente, uma função que foi feita para retornar bool está a retornar void.. 😶 e ainda pede mais parâmetros que aos indicados dentro do WCF que seriam o Email e a Password, visto que serve para verificar o login. O WCF funciona perfeitamente, não estou realmente é a conseguir unir o cliente ao serviço.. O código a baixo é o WCF: public bool Login(string email, string password) { bool ativo = false; try { if (string.IsNullOrEmpty(email) == false && string.IsNullOrEmpty(password) == false) { var comando = new SqlCommand(); comando.Connection = Connection.conexao_DB; Connection.Conetar_DB(); SqlDataAdapter cmd = new SqlDataAdapter("SELECT * FROM login where email = @Email and password = @Password", Connection.conexao_DB); cmd.SelectCommand.Parameters.Add(new SqlParameter("@Email", email)); cmd.SelectCommand.Parameters.Add(new SqlParameter("@Password", password)); DataTable dt = new DataTable(); cmd.Fill(dt); List<LoginModel> getUser = new List<LoginModel>(); foreach (DataRow row in dt.Rows) { LoginModel user = new LoginModel(); user.Email = row["email"].ToString(); user.Password = row["password"].ToString(); if (email == row["email"].ToString() && password == row["password"].ToString()) { ativo = true; }; getUser.Add(user); } Connection.Desconetar_DB(); //return ativo; } } catch (Exception) { throw new FaultException("ERROR"); } return ativo; } Dentro do IService.cs: namespace WcfMarketPlace { [ServiceContract] public interface IService { [OperationContract] bool Login(string email, string password); } } Do lado do cliente: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using TESTE.wcfMarketPlace; namespace TESTE { public partial class Login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } public void loginT_Click(object sender, EventArgs e) { try { wcfMarketPlace.Service wcf = new wcfMarketPlace.Service(); bool ativo = false; ativo = wcf.Login(loginEmail.Text, loginPassword.Text); } catch { Response.Write("<script>alert('Usuario Incorreto')</script>"); } //wcf.Close(); } } } Até pode ser um erro básico, mas realmente não entendo visto que sou iniciante, agradeço qualquer tipo de ajuda! Obrigado! Renato Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now