简体   繁体   中英

.NET Core 2.0 soap client call fails with “WinHttpException: The operation timed out”

I have a simple soap client developed in .Net core 2.0 to consume calculator methods from the following web service: http://www.dneonline.com/calculator.asmx?WSDL The service is imported into Visual Studio 2017 as a connected service and the code that calls the service methods looks as below:

        var binding =  new BasicHttpBinding(BasicHttpSecurityMode.None);
        var ep = new EndpointAddress("http://www.dneonline.com/calculator.asmx?WSDL");

        Calculator.CalculatorSoapClient client =
            new Calculator.CalculatorSoapClient(binding, ep);

        client.AddAsync(1, 3).Wait();
        Console.WriteLine("Finished successfully");
        Console.ReadLine();

Now the thing is that this code fails after 20 seconds when calling the AddAsync methodwith an exception of "WinHttpException: The operation timed out". Other relevant observations:

  1. The exact same code (incluing the generated connected service) works well in VS 2015 with .NET Framework.
  2. Our dev machines are behind the company firewall and by that the wirshark trace looks different between the two executions. The successfull run on .NET Framework can establish the connection while the other one cannot connect to the proxy.
  3. I have seen other articles talking about increasing the timeout value on long running or heavy calls but this one is neither heavy nor a long running method.

Has anyone faced any similar issue or knows why .NET core behaves differently?

Update 1 We tested the solution on a cloud based computer and it worked fine. So, it looks to be the company firewall blocking the outgoing communication. On the other hand on the same local computer, we tested a simple .Net Core application that downloads an image from a website and that worked well too. This is all while VS 2015 with .NET Framework has no problem running the same code, calling a web service and fetching the results. So, the new question can be why .NET Core behaves differently on the network communication? Is there any new rule, policy, permission, restriction, capability, etc that needs to be turned on/off to enable coomunication with the internet?

There was a bug in .net Core 2.0 with proxy configuration, as you could see here: https://github.com/dotnet/wcf/issues/1592 .

The solution for my project (VS 2017/.net Core 2.0) was to upgrade it to .net Core 2.1, and update System.ServiceModel.Http and other dependencies to latest stable (4.5.3 in my case). Then the IE/Edge proxy settings are used.

This question is possibly a duplicate of: Connecting to a SOAP service with .Net Core 2.0 behind a proxy

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