简体   繁体   English

NET Core 2.1中的SAP WS WCF客户端使用错误405

[英]SAP WS WCF client consumption error 405 in .net core 2.1

I am trying to use a web service from SAP that requires authentication. 我正在尝试使用需要身份验证的SAP Web服务。 I added web service successfully. 我成功添加了Web服务。 however, when I want to use it (httpGet) it gives me error 405 Method Not Allowed 但是,当我想使用它(httpGet)时,出现错误405

I tried using another webservice with authentication and it worked. 我尝试将另一个Web服务与身份验证一起使用,并且可以正常工作。

I tried using current web service in SOAP UI and it works perfectly fine. 我尝试在SOAP UI中使用当前的Web服务,并且运行良好。

I tried using factory with httpBinding with BasicHttpSecurityMode.TransportCredentialOnly and myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; 我尝试将带有httpBinding的Factory与BasicHttpSecurityMode.TransportCredentialOnly and myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

I re-checked Uri with service provider and it's correct. 我与服务提供商重新检查了Uri,这是正确的。

I checked windows features: 我检查了Windows功能:

  • Windows communication foundation HTTP Activation is checked, Windows Communication Foundation HTTP激活已检查,
  • Windows communication foundation HTTP Non-Activation is checked. Windows Communication Foundation HTTP非激活已选中。
  • WCF Services: WCF服务:
  • HTTP Activation is checked, 检查HTTP激活,
  • named Pipe activation is checked, 检查名为“管道激活”的管道,
  • TCP Activation is checked, 检查TCP激活,
  • TCP Port sharing is checked. 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: The remote server returned an unexpected response: (405) Method Not Allowed. ProtocolException:远程服务器返回了意外的响应:(405)不允许的方法。

In most cases, the way you call the service is a standard SOAP invocation, namely, the below request based on HTTP-POST other than HTTP-GET. 在大多数情况下,调用服务的方式是标准的SOAP调用,即以下基于HTTP-POST而非HTTP-GET的请求。

var x = await _serviceClient.ServiceFunctionAsync(i); var x =等待_serviceClient.ServiceFunctionAsync(i);


when I want to use it (httpGet) it gives me error 405 Method Not Allowed 当我想使用它(httpGet)时,出现错误405

How do you define the service contract? 您如何定义服务合同? I mean that the published service might use webhttpbinding to create a Restful style service. 我的意思是发布的服务可能使用webhttpbinding创建Restful风格的服务。 Under this circumstance, if we want to call the service by using the client proxy class, we need to add Webhttp endpoint behavior to the auto-generated service endpoint. 在这种情况下,如果要使用客户端代理类调用服务,则需要将Webhttp端点行为添加到自动生成的服务端点中。 Also, add [webget] to the operation contract. 另外,将[webget]添加到操作合同中。 Please refer to my demo. 请参考我的演示。
WCF: There was no endpoint listening at, that could accept the message WCF:没有端点在侦听,可以接受消息
Simply speaking, we should ensure the binding is consistent between the client and the server when calling the service by using client proxy. 简而言之,在使用客户端代理调用服务时,我们应确保客户端和服务器之间的绑定是一致的。
Please share the server binding details with us so that I could reproduce your problem and locate the problem precisely. 请与我们分享服务器绑定的详细信息,以便我可以重现您的问题并精确定位问题。
Feel free to let me know if the problem still exists. 随时让我知道问题是否仍然存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM