本文介绍了.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与绑定的内容类型不匹配(文本/ 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?

感谢
Imrankhan

ThanksImrankhan

推荐答案

这是解决您问题的方法:

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 19:13