“Add service reference“ vs “Add connected service“ issues

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值