简体   繁体   中英

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. I added web service successfully. however, when I want to use it (httpGet) it gives me error 405 Method Not Allowed

I tried using another webservice with authentication and it worked.

I tried using current web service in SOAP UI and it works perfectly fine.

I tried using factory with httpBinding with BasicHttpSecurityMode.TransportCredentialOnly and myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

I re-checked Uri with service provider and it's correct.

I checked windows features:

  • Windows communication foundation HTTP Activation is checked,
  • Windows communication foundation HTTP Non-Activation is checked.
  • WCF Services:
  • HTTP Activation is checked,
  • named Pipe activation is checked,
  • TCP Activation is checked,
  • TCP Port sharing is checked.

     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.

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.

var x = await _serviceClient.ServiceFunctionAsync(i);


when I want to use it (httpGet) it gives me error 405 Method Not Allowed

How do you define the service contract? I mean that the published service might use webhttpbinding to create a Restful style service. 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. Also, add [webget] to the operation contract. Please refer to my demo.
WCF: There was no endpoint listening at, that could accept the message
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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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