I want to access a method of a webservice made in C#

Asked

Viewed 115 times

0

I am trying to access the Login method of a certain webservice, but instead of returning the . Token I ask in reply, I get a pure HTML from webservice

My code js:

$.ajax({

      crossDomain: "true",
      //contentType: "text/xml",
      //type: "POST",
      url: "http://macchips.macpontoweb.com.br/wsvisita/services/comum/autenticacao/autenticacaosrv.svc?Login",
      data: {

        usuario: client.value,
        senha: senha.value,

      },

      success: function(resposta){


       alert(resposta.Token);

      },

      error: function(error){
        var falha = JSON.stringify(error);

        alert("Erro " + falha);
      }

    });

The lines type and contenttype are commented on. I believe I need them but I’m not sure

I’m trying to access the webservice via an application I’m developing

/////EDIT///////

I made some changes, now I’m getting a readyState:4, status:200, statusText:load

My changed code:

 $.ajax({

 type: "POST",
          crossDomain: "true",
          dataType: "jsonp",
          contentType: "text/xml", 
          url: "http://macchips.macpontoweb.com.br/WSVisita/Services/Comum/Autenticacao/AutenticacaoSrv.svc",
          data: {
              Login: 'wellington, wellington'
          },

          success: function(resposta){ 

           window.location.href="login.html";

           alert(resposta);

          },

          error: function(jqxhr, error){
            var falha = JSON.stringify(error);

            alert("Erro " + falha);
          }

        });
  • 2 things: 1. You are not using java, are using javascript. 2. Have you seen what this HTML says? It can be useful.

  • In addition to uncomment the lines change the "url" to: http://macchips.macpontoweb.com.br/wsvisita/services/comum/autenticacao/autenticacaosrv/Login

  • It didn’t work, I get an error alert with the HTML of the webservice page and status 404

  • Yes, it is the html of the webservice page

  • the link I sent you missed the extension ". svc", with it works?

  • Still not working, but now I’m getting a status 400 error, bad request

  • Was Webservice made by you? It is designed to receive requests from other domains?

  • It wasn’t made by me, but it was designed for this, so I believe you have all the necessary authorizations

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.