Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

uwp - WSHttpBinding in .NetStandard or .NET core

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.

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;

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?

Thanks Imrankhan

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...