My role calling my web service
var email = document.getElementById("email").value
var senha = document.getElementById("senha").value
$.ajax({
url: "http://localhost:8080/Servidor/rest/service/loginCustmerUser/"+ email + ","+ senha,
dataType: "json",
type: "GET",
async: false,
success: function (data) {
alert(data)
},
error: function(e){
alert("Erro: " + e);
},
});
My method in webservice
@GET
@Produces("application/json")
@Path("/loginCustmerUser/{email},{senha}")
public String loginClientUser(@PathParam("email") String email,
@PathParam("senha") String senha) {
NotaFiscalBO bo = new NotaFiscalBO();
CustmerUser cUser = bo.loginCustmerUser(email);
try {
boolean validacao = validarCustmerUserLogin(senha,
cUser.getPassword());
if (!validacao) {
cUser = null;
}
} catch (Exception e) {
e.printStackTrace();
}
return new Gson().toJson(cUser);
}
Method Return
{"id": 3, "login": "test", "password": "2482e34cc83b09ba9088b2af8bf11866"}