O erro é esse:
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.
Tenho dois Projetos:
1º WebService, pra rodar o 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;
}
}
2º WindowsPhone, uso emulador para rodar.
Foi adicionado a Referencia com o nome de "DadosService" e link "http:/ /localhost:27128/WebService.asmx" (sem espaços)
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");
}
}