Exception when accessing web service in Xamarin.Forms application

Asked

Viewed 153 times

0

I’m creating an application with Xamarin with Visual Studio 2017. I did all the tests on the web service and it accesses the database and records everything perfectly in the browser version. I have now made an implementation in the Xamarin application and in this case an exception is occurring when initializing the database. The database already exists and there is already recorded data in the database. I made the publication using internet information services (iis) in windows 10. The descriptions of the exceptions are below.

Message

System.Web.Services.Protocols.Soapexception: The server could not process the request. ---> System.Exception: An Exception occurred while initializing the database. See the Innerexception for Details.
in Servicewebflipdigital.WSFlipDigital.Gravaragencia(String jsonAgencia) in C: Users davinc131 Documents visual studio 2017 Projects Webserviceflipdigital Servicewebflipdigital Wsflipdigital.asmx.Cs:line 65 --- End of stack tracking of internal exceptions ---

Tracke

at FlipDigital.Droid.Implementacoes.Dados.ImplementGravarAgencia.GravarAgencia (System.String jsonAgencia) [0x0001f] in E: Projects_xamarin Flipdigital Flipdigital Flipdigital.Android Implementations Data Implementgravaragencia.Cs:49 at FlipDigital.Portatil.GravarAgenciaManager.GravarAgencia (System.String jsonAgencia) [0x00001] in E: Projects_xamarin Flipdigital Flipdigital Flipdigital Portatil Gravaragenciamanager.Cs:15 at FlipDigital.Views.FlipDigital_CadastroAgencia+d__5.MoveNext () [0x0017d] in E: Projects_xamarin Flipdigital Flipdigital Flipdigital Views Flipdigital_cadastroagencia.xaml.Cs:71

What may be occurring and how to proceed to resolve the problem?

IN XAMARIN

Interface

public interface IGravarAgencia
{
    void GravarAgencia(string jsonAgencia);

    void ModificarAgencia(string jsonAgencia);

    Agencia ConsultarAgencia(int idAgencia);

    void RemoverAgencia(int idAgencia);

    List<Agencia> ListarAgencias();
}


public void GravarAgencia(string jsonAgencia)
    {
        DependencyService.Get<IGravarAgencia>().GravarAgencia(jsonAgencia);
    }

That is the implementation`

public void GravarAgencia(string jsonAgencia)
    {
        try
        {
            wsFlipDigital = new WebServiceFlipDigital.WSFlipDigital();
            wsFlipDigital.GravarAgencia(jsonAgencia);
        }
        catch (Exception e)
        {

            throw new Exception(e.Message);
        }
    }

ON THE WEB SERVICE

[WebMethod(Description = "Grava uma agencia no banco de dados.")]
    public bool GravarAgencia(string jsonAgencia)
    {
        try
        {
            Agencia ag = new Agencia();

            ag = DeserializarAgencia(jsonAgencia);
            //negocioAgencia.GravarAgencia(ag.NomeAg.ToUpper(), ag.FotoUsuario, ag.NomeDeUsuario, ag.Email, ag.Telefone, ag.Senha);
            //return true;


            if (negocioAgencia.ValidarTudo(ag.NomeAg, ag.NomeAg, ag.Telefone, ag.Email).Equals(true))
            {
                negocioAgencia.GravarAgencia(ag.NomeAg.ToUpper(), ag.FotoUsuario, ag.NomeDeUsuario, ag.Email, ag.Telefone, ag.Senha);
                return true;
            }
            else
            {
                return false;
            }
        }
        catch (Exception e)
        {
            throw new Exception(e.Message);
        }
    }

Just to remind that in the browser the persistence process happens normally, with no exceptions.

  • The error is in the webservice, log the error and you will see what is wrong.

  • I just saved the data using the browser version and no error occurred. The data was persisted normally. The exception is occurring only in the application.

  • And does that mean anything? The mistake says: "The server could not process the request". It is clear that the error is in web service. In fact, it’s really hard trying to help you without seeing any code.

  • That one throw new Exception(e.Message); is terrible because you end up losing Exception source information.

No answers

Browser other questions tagged

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