0
I have an api that accepts the post request with json and xml for Pedidocompra, for cases where I receive the xml is occurring an anomalous request cancellation, that is, some enter the api and others fall as cancelled request.
public static void ConfigureWebApi(HttpConfiguration config)
{
// Remove o XML
var formatters = config.Formatters;
var xml = formatters.XmlFormatter;
xml.UseXmlSerializer = true;
xml.Indent = true;
xml.SetSerializer<Application.API.ViewModels.v1.Processo.ProcessoViewModel>(new XmlSerializer(typeof(Application.API.ViewModels.v1.Processo.ProcessoViewModel)));
xml.SetSerializer<Application.API.ViewModels.v2.Processo.ProcessoViewModel>(new XmlSerializer(typeof(Application.API.ViewModels.v2.Processo.ProcessoViewModel)));
xml.SetSerializer<Application.API.ViewModels.v1.Invoice.InvoiceViewModel>(new XmlSerializer(typeof(Application.API.ViewModels.v1.Invoice.InvoiceViewModel)));
xml.SetSerializer<Application.API.ViewModels.v2.Invoice.InvoiceViewModel>(new XmlSerializer(typeof(Application.API.ViewModels.v2.Invoice.InvoiceViewModel)));
xml.SetSerializer<Application.API.ViewModels.v2.PedidoCompra.PedidoCompraViewModel>(new XmlSerializer(typeof(Application.API.ViewModels.v2.PedidoCompra.PedidoCompraViewModel)));
xml.SetSerializer<ListaDespesasViewModel>(new XmlSerializer(typeof(ListaDespesasViewModel)));
xml.SetSerializer<ListaNumerarioViewModel>(new XmlSerializer(typeof(ListaNumerarioViewModel)));
xml.SetSerializer<TesteViewModel>(new XmlSerializer(typeof(TesteViewModel)));
// Modifica a identação
var jsonSettings = formatters.JsonFormatter.SerializerSettings;
jsonSettings.Formatting = Formatting.Indented;
jsonSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
// Modifica a serialização
formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
in the log the only message I get in the error is 2021-02-11 14:27:52.2552
Info Portal.API.Handlers.ErrorHandlingFilter.Onexception - Errorhandlingfilter Message: The Operation was canceled. 2021-02-11 14:27:52.2552 Info Portal.API.Handlers.ErrorHandlingFilter.Onexception - Errorhandlingfilter Innerexception: 2021-02-11 14:27:52.2552 Info Portal.API.Handlers.ErrorHandlingFilter.Onexception - Errorhandlingfilter Innerexception: 2021-02-11 14:27:52.2552 Error Portal.API.Handlers.ErrorHandlingFilter.Onexception - Errorhandlingfilter Exceptionlogger -> 2021-02-11 14:27:52.2552 Error Portal.API.Handlers.ErrorHandlingFilter.Onexception
- Message : Errorhandlingfilter Exceptionlogger ->
- Errorsource :
- Errorclass :
- Errormethod :
- Errormessage :
- Errorlinenumber :
- Innererrormessage :
- Stackerrormessage :
A detail sending the request via Swagger this problem does not occur, but if the client sends from the ERP this occurs, the request is not being canceled after sending and yes during the processing of the request, but does not show error or log of the reason.
Has anyone ever had this problem or has any idea what might cause this problem?
Do you have a way to verify the Xmls that ERP is sending? Both in case of success and failure? You used this evidence to debug your code?
– Leandro Angelo
yes, if I take the xml I receive and apply via Swagger gives success, I have tried debugging but the problem does not occur.
– Nivaldo Frigo
I also checked the alternatives I found on this link: https://qastack.com.br/programming, now I’m going to test the last of the list
– Nivaldo Frigo