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.
– Giuliana Bezerra
@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
WCFor is using the old model for asymptomatic requests (usingDuplexChannel,CallbackContractand MethodsOneWay). In this case, you will have to suspend thethreadand wait for the return through theCallbackto continue... if you are using the simplified model for asynchronous requests fromWCF, just use theasync/awaitin hisController.– Tobias Mesquita
you could add the section
configuration/system.serviceModelin your question, you can and should hide more sensitive sections, such as thesecuritywithin thebindingand theaddresswithin theclient/endpoint. but the type ofbindingand its configuration are important.– Tobias Mesquita
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.
– Pizzanio