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");
}
}