Error while consuming ASMX Web Service

Asked

Viewed 780 times

0

That is the mistake:

An exception of type 'System.ServiceModel.CommunicationException' occurred in System.ServiceModel.ni.dll but was not handled in user code

Additional information: The remote server returned an error: NotFound. 

I have two Projects:

1st Webservice, to run the Web Service

WebService.asmx:

[WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class WebService : System.Web.Services.WebService
    {
        [WebMethod]
        public Boolean Autenticar(string usuario, string senha)
        {
            if (usuario == "admin" && senha == "admin")
                return true;
            return false;
        }
    }

2nd Windowsphone, use emulator to run.

Reference was added with the name "Dadosservice" and link "http:/ /localhost:27128/Webservice.asmx" (no spaces)

MainPage.xaml.cs

private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            DadosService.WebServiceSoapClient service = new DadosService.WebServiceSoapClient();
            service.AutenticarCompleted += service_AutenticarCompleted;
            service.AutenticarAsync("admin", "admin");
        }

        public void service_AutenticarCompleted(object sender, DadosService.AutenticarCompletedEventArgs e)
        {
            if (e.Result)
            {
                MessageBox.Show("Certo");
            }
            else
            {
                MessageBox.Show("Errado");
            }
        }
  • @Thiagosilva published it on IIS as "http://192.168. 2.102:8080/Service/" and still gives the same error

  • @Tiagosilva I can’t do it!

2 answers

0

Try it this way:

    private void button1_Click(object sender, EventArgs e)
    {
        DadosSevice.WebServiceSoapClient service = new DadosSevice.WebServiceSoapClient();
        bool validou = service.Autenticar ("admin", "admin");

        //test the return from webservice
        if (validou)
        {
            MessageBox.Show("Validou");
        }
    }

0


Browser other questions tagged

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