Access to Asynchronous Webservice

Asked

Viewed 48 times

0

I am working on a project, where I run an asynchronous webservice (project pattern), but I am in trouble because the webservice has not yet completed the execution and my continuous processing (causing errors).

Is there any way I can do to only continue processing after finishing the execution of the web service?

Follow a part of the code where I call the webservice(record history) after a change. I need the process to continue (redirect), only after the entire execution of the webservice (I cannot change the webservice):

public ActionResult EditarConfirmed(EditarAnotacoesAdministrativasViewModel viewModel, long? handlePeg, long id)
        {
            if (ModelState.IsValid)
            {
                viewModel.Entidade.Handle = id;
                repositorio.Altera(viewModel.Entidade);

                var proxy = new AnotacoesAdmPegServiceClient();
                var handleAnotacao = new anotacaoAdministrativaId() { codigo = viewModel.Entidade.Handle };

                proxy.gravarHistorico(2, handleAnotacao);

                return RedirectToAction("Index", new { Id = viewModel.Entidade.Handle });
            }
            else
            {
                return View(viewModel);
            }
        }
  • Yes, but the answer depends on the framework you are calling the webservice. Put the service client code here so we can work out a response.

  • @Pizzanio, without knowing the structure of the service, it is difficult to help you, in any case your webservice seems not to be done using WCF or is using the old model for asymptomatic requests (using DuplexChannel, CallbackContract and Methods OneWay). In this case, you will have to suspend the thread and wait for the return through the Callback to continue... if you are using the simplified model for asynchronous requests from WCF, just use the async/await in his Controller.

  • you could add the section configuration/system.serviceModel in your question, you can and should hide more sensitive sections, such as the security within the binding and the address within the client/endpoint. but the type of binding and its configuration are important.

  • I tried to use async/await, but this does not give a version error apparently, I researched about the error and he asks me to include some Packages, but I do not have authorization for this. It is a project where the client does not authorize me to leave much of the standard of the existing environment.

No answers

Browser other questions tagged

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