Hi
What is the difference between "Add service reference" in Visual Studio 2015 and "Add connected service" in Visual Studio 2017 I wonder? The thing is I am porting a project from VS 2015 with .net framework 4.5.2 to VS 2017 with .net Core 2.0 which contains calls to some enterprise web service.
The first thing I noticed is that the latter only creates Async method so I had to update the client code as well to call the *Async version for every method which went well. Just for my own curosity I also update the legacy code to use the same Async methods, tested it and was OK.
However, the same method and exactly the same client code fails when executed on .net core. I don't understand why. It fails with an error returned from the service stating that the WS security header is missing and that's while the security header is provided via the OperationContext exactly the same way we did it before for the 2015 version and worked.
I cannot reveal the details about the service we are using but look below for how the service is being called and the secuity header is injected:
var securityHeader = new SecurityHeader("id", "", "");
var client = new TerminalPortTypeClient();
var clientChannel = client.InnerChannel;
using (new OperationContextScope(clientChannel))
{
OperationContext.Current.OutgoingMessageHeaders.Add(securityHeader);
var resAsync = client.GetTerminalsAsync(...);
var svar = resAsync.Result; // here it fails on .net core
}
To me it looks like the .net core proxy some where on the way drops out the injected header.
Hope someone can help me understand the reason behind the failure or suggest a way out.
regards
R.
The difference between "Add Service Reference" and "Add Connected Service" is whether the generated proxy can run on .NET Core (Connected Service) or on the full .NET Framework (Service Reference). WCF on .NET Core does not support all the same features as WCF on the full framework, so the proxy has to be generated differently.
The reason you're seeing an error when calling the service is because WS Security is not supported by WCF on .NET Core.