.NetStandard 或 .NET core 中的 WSHttpBinding [英] WSHttpBinding in .NetStandard or .NET core

查看:32
本文介绍了.NetStandard 或 .NET core 中的 WSHttpBinding的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序中集成 NMVS 协议,该应用程序提供 wsdl 文件用于测试,这些文件是在 .net 框架库中编写的示例代码.

I want to integrate NMVS protocol in my application which is providing wsdl files for testing which is written sample code in .net framework library.

我想在 .netstandard、.netcore 或 UWP 应用程序中对其进行测试,但 wsdl 文件仅支持WSHttpBinding",而在 .netstandard、.net core 和 UWP 中不支持.

I want to test it in .netstandard, .netcore or UWP app but wsdl files only support to "WSHttpBinding" which is not supported in .netstandard, .net core and UWP.

 <wsdl:binding name="WSHttpBinding_ISinglePackServices" type="ns:ISinglePackServices">



WSHttpBinding binding = new WSHttpBinding();
 binding.Security.Mode =  SecurityMode.Transport;
 binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;

我使用了 basichttpbinding 但我收到错误消息响应消息的内容类型 application/soap+xml; charset=UTF-8 与绑定的内容类型 (text/xml; charset=utf-8)."

I used basichttpbinding but I am getting error that says "The content type application/soap+xml; charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8)."

还有哪些其他方法可以解决此问题?

What are the other ways to troubleshoot this issue?

谢谢伊姆兰罕

推荐答案

以下是您问题的解决方案:

Here is a solution for your problem :

var transportSecurityBinding = new BasicHttpBinding();
transportSecurityBinding.Security.Mode = BasicHttpSecurityMode.Transport;
transportSecurityBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;

var customTransportSecurityBinding = new CustomBinding(transportSecurityBinding);

var textBindingElement = new TextMessageEncodingBindingElement
{
      MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None)
};

// Replace text element to have Soap12 message version
customTransportSecurityBinding.Elements[0] = textBindingElement;

这篇关于.NetStandard 或 .NET core 中的 WSHttpBinding的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆