Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 315
Imrankhan Avatar asked Nov 15 '18 14:11

Imrankhan


People also ask

Does .NET core support WSHttpBinding?

Net Core does not support WSHttpBinding.

Can we use WCF in .NET core?

NET Core and . NET 5 support calling WCF services, but won't offer server-side support for hosting WCF. There are two recommended paths for modernizing WCF apps: gRPC is built on modern technologies and has emerged as the most popular choice across the developer community for RPC apps.

Does .NET core support SOAP?

NET Core platform. It provides a compatible implementation of SOAP, NetTCP, and WSDL. Usage in code is similar to WCF, but updated to use ASP.NET Core as the service host, and to work with .

Is Grpc faster than WCF?

What can we do to make GRPC run a little faster/leaner? GRPC is better than WCF in terms of performance. You can refer to the following link, which compares WCF with GRPC.learn.microsoft.com/en-us/dotnet/architecture/…


1 Answers

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;
like image 98
Nicolas Giannone Avatar answered Sep 28 '22 22:09

Nicolas Giannone