Dha*_*rma 3 c# asp.net-core-webapi asp.net-core-2.2
在 asp.net core 2.2 中使用 Galileo Flight UAPI API 时出现错误。当调用异步方法时出现一个错误
提供的 URI 方案“https”无效;预期为“http”。参数名称:via
我已经根据 .net core 的要求更新了 lib 并更改了 BasicHttpBinding
我根据谷歌和 Stackoverflow 搜索更改了代理
private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
{
if ((endpointConfiguration == EndpointConfiguration.AirLowFareSearchPort))
{
System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
result.MaxBufferSize = int.MaxValue;
result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
result.MaxReceivedMessageSize = int.MaxValue;
result.AllowCookies = true;
result.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
result.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Ntlm;
result.TransferMode = System.ServiceModel.TransferMode.Buffered;
return result;
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}
Run Code Online (Sandbox Code Playgroud)
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
AirLowFareSearchPortTypeClient client =
new AirLowFareSearchPortTypeClient(AirLowFareSearchPortTypeClient.EndpointConfiguration.AirLowFareSearchPort, uRL + "/AirService");
client.ClientCredentials.UserName.UserName = username;
client.ClientCredentials.UserName.Password = password;
var httpHeaders = Helper.ReturnHttpHeader(username, password);
client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));
SessionContext context = new SessionContext();
var serviceResponse = await client.serviceAsync(context, lowFareSearchReq);
Run Code Online (Sandbox Code Playgroud)
创建自己的BasicHttpBinding对象并设置“Transport”Security.Mode等属性,分配给PortType Client。这是代码。
System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
binding.MaxBufferSize = int.MaxValue;
binding.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
binding.MaxReceivedMessageSize = int.MaxValue;
binding.AllowCookies = true;
binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
binding.TransferMode = System.ServiceModel.TransferMode.Buffered;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
var endpoint = new EndpointAddress(uRL + "/AirService");
//AirLowFareSearchPortTypeClient client = new AirLowFareSearchPortTypeClient(AirLowFareSearchPortTypeClient.EndpointConfiguration.AirLowFareSearchPort, uRL + "/AirService");
AirLowFareSearchPortTypeClient client = new AirLowFareSearchPortTypeClient(binding, endpoint);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7581 次 |
| 最近记录: |