Error consuming ASMX Web Service

0

The error is this:

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 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 has been added with the name "DataService" and link "http: //localhost:27128/WebService.asmx" (without 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");
            }
        }
    
asked by anonymous 06.08.2014 / 21:53

2 answers

0

I discovered the error from this link:

  

link

I disabled the firewall and everything worked!

    
12.08.2014 / 14:41
0

Try this:

    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");
        }
    }
    
09.08.2014 / 05:20