这很奇怪,来自微软。在Visual Studio中,当我从Visual Studio执行应用程序代码时,大多数时候都会收到以下错误,然后将代码发布到自己的服务器上,Web应用程序运行正常(发出请求时没有任何错误),并且从我的PC(与Visual Studio所在的PC是同一台PC)上,我向soapUI发出了相同的请求,我从调用的服务器URL中没有收到任何错误。为什么我会从Visual Studio中收到此错误,然后进行修复。
出于安全原因,我无法提供该网址。
System.AggregateException
HResult=0x80131500
Message=One or more errors occurred. (An error occurred while sending the request.)
Source=System.Private.CoreLib
Arborescence des appels de procédure :
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Amadeus.Endpoint.call(String body) in C:\Users\Gervil Doubal\source\repos\Acompa chart\Amadeus\Endpoint.cs:line 175
at Amadeus.EndpointGeneric`2.call() in C:\Users\Gervil Doubal\source\repos\Acompa chart\Amadeus\EndpointGeneric.cs:line 32
at OnlineAgency.Controllers.CarController.userInfo() in C:\Users\Gervil Doubal\source\repos\Acompa chart\OnlineAgency\Controllers\CarController.cs:line 402
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()
Exception interne 1 :
HttpRequestException : An error occurred while sending the request.
Exception interne 2 :
WinHttpException : Le serveur a renvoyé une réponse non valide ou non reconnue
InnerException:
{System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.WinHttpException: Le serveur a renvoyé une réponse non valide ou non reconnue
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Threading.Tasks.RendezvousAwaitable`1.GetResult() at System.Net.Http.WinHttpHandler.<StartRequest>d__105.MoveNext() --- End of inner exception stack trace --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() at System.Net.Http.DiagnosticsHandler.<SendAsync>d__2.MoveNext()--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() at System.Net.Http.HttpClient.<FinishSendAsyncBuffered>d__58.MoveNext()--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Amadeus.Endpoint.<_call>d__33.MoveNext() in C:\Users\Gervil Doubal\source\repos\Acompa chart\Amadeus\Endpoint.cs:line 131}
消息:An error occurred while sending the request.
来源:"System.Private.CoreLib"
其他InnerException:
{System.Net.Http.WinHttpException (0x80072F78): Le serveur a renvoyé une réponse non valide ou non reconnue (The server returned an invalid or unrecognized response)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.Tasks.RendezvousAwaitable`1.GetResult()
at System.Net.Http.WinHttpHandler.<StartRequest>d__105.MoveNext()}
ErrorCode:-2147012744
NativeCodeError:12152
来源:"System.Private.CoreLib"
StackTrace:
" at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Threading.Tasks.RendezvousAwaitable`1.GetResult()\r\n at System.Net.Http.WinHttpHandler.<StartRequest>d__105.MoveNext()"
调用函数我删除了一些与http-client无关的逻辑代码:
private async Task<String> _call(String body)
{
var client = new HttpClient();
client.DefaultRequestHeaders.Clear();
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("text/xml"));
client.DefaultRequestHeaders.Add("SoapAction", action + "/" + service);
client.Timeout = TimeSpan.FromMinutes(3);
StringContent httpContent = new StringContent(xml, Encoding.UTF8, "text/xml");
HttpResponseMessage resp = await client.PostAsync(url + "/" + wSAP, httpContent);
return await resp.Content.ReadAsStringAsync();
}
电话是:
var resp = _call(body);
return resp.Result;