【问题标题】:SAP WS WCF client consumption error 405 in .net core 2.1.net core 2.1 中的 SAP WS WCF 客户端消耗错误 405
【发布时间】: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


【解决方案1】:

在大多数情况下,您调用服务的方式是标准的 SOAP 调用,即以下基于 HTTP-POST 而非 HTTP-GET 的请求。

var x = await _serviceClient.ServiceFunctionAsync(i);


当我想使用它时 (httpGet) 它给了我错误 405 Method Not 允许

您如何定义服务合同?我的意思是发布的服务可能会使用 webhttpbinding 来创建一个 Restful 风格的服务。在这种情况下,如果我们想通过客户端代理类调用服务,我们需要在自动生成的服务端点中添加Webhttp端点行为。另外,将 [webget] 添加到操作合同中。请参考我的演示。
WCF: There was no endpoint listening at, that could accept the message
简单来说,使用客户端代理调用服务时,要保证客户端和服务端的绑定一致。
请与我们分享服务器绑定详细信息,以便我可以重现您的问题并准确定位问题。
如果问题仍然存在,请随时告诉我。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-02
    • 1970-01-01
    • 1970-01-01
    • 2019-04-10
    • 1970-01-01
    • 2020-03-03
    • 1970-01-01
    • 2017-03-28
    相关资源
    最近更新 更多