【发布时间】:2019-07-18 05:24:09
【问题描述】:
我正在尝试使用需要身份验证的 SAP 网络服务。 我成功添加了网络服务。但是,当我想使用它(httpGet)时,它给了我错误 405 Method Not Allowed
我尝试使用另一个具有身份验证功能的 Web 服务,它成功了。
我尝试在 SOAP UI 中使用当前的 Web 服务,它运行良好。
我尝试使用带有 httpBinding 和 BasicHttpSecurityMode.TransportCredentialOnly and myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; 的工厂
我与服务提供商重新检查了 Uri,它是正确的。
我检查了 Windows 功能:
- Windows 通信基础 HTTP 激活已检查,
- 已检查 Windows 通信基础 HTTP 未激活。
- WCF 服务:
- HTTP 激活已检查,
- 已检查命名管道激活,
- 已检查 TCP 激活,
-
已检查 TCP 端口共享。
public testWS(IConfiguration configuration) { _configuration = configuration; endpoint = new EndpointAddress(new Uri("link")); _serviceClient = new ServiceClient(EndpointConfiguration.HTTP_Port, endpoint); _serviceClient.ClientCredentials.UserName.UserName = "username"; _serviceClient.ClientCredentials.UserName.Password = "Password"; } public async Task<ServiceResponse> getAccount2() { var i = new ServiceRequest(); var x = await _serviceClient.ServiceFunctionAsync(i); return x; }
ProtocolException:远程服务器返回了意外响应:(405) Method Not Allowed。
【问题讨论】:
-
405 Method not allowed通常在您使用get动词调用post端点时发生,反之亦然。如果soapui的调用与您的代码不同,请与fiddler核实。
标签: c# .net wcf asp.net-core soap