question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating CustomBinding with UsernameTransport in .net core 3.1

See original GitHub issue

I’m trying to consume a WCF service that creates a binding like this in a full framework project.

<customBinding>
	<binding name="CustomBinding_IClaimService">
		<security defaultAlgorithmSuite="Default" authenticationMode="UserNameOverTransport" requireDerivedKeys="true" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
			<localClientSettings detectReplays="false" />
			<localServiceSettings detectReplays="false" />
		</security>
		<textMessageEncoding messageVersion="Soap12" />
		<httpsTransport />
	</binding>
	<binding name="CustomBinding_IIssueService">
		<security defaultAlgorithmSuite="Default" authenticationMode="UserNameOverTransport" requireDerivedKeys="true" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
			<localClientSettings detectReplays="false" />
			<localServiceSettings detectReplays="false" />
		</security>
		<textMessageEncoding messageVersion="Soap12" />
		<httpsTransport />
	</binding>
</customBinding>

I can’t seem to get this replicated in a .net core 3.1 project though. I am getting this error message no matter what kind of binding I try programatically.

The message with Action ‘’ cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mconnewcommented, Apr 21, 2020

@Heraisu , I see your problem. I’m not sure if it’s your intention, but you are actually trying to make a mixed mode binding. You are specifying client certificate for transport, but Windows for Message. So you are requesting using the Negotiate protocol over SOAP messages. I suspect this is actually what you want:

var wsBinding = new WSHttpBinding(SecurityMode.TransportWithMessageCredential);
wsBinding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;

You were setting transport security credential type to Certificate, but not setting message security credential type. That defaults to Windows which isn’t supported.

0reactions
Heraisucommented, Apr 17, 2020

Yes, I am not the original poster, thank you for still offering to give feedback on my issue. The following is enough to reproduce the error:

var wsBinding = new WSHttpBinding(SecurityMode.TransportWithMessageCredential); wsBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;

(Are Certificates one of the things that, as you mentioned, are unsupported?) The call stack: "Specified method is not supported." at System.ServiceModel.MessageSecurityOverHttp.CreateSecurityBindingElement(Boolean isSecureTransportMode, Boolean isReliableSession, MessageSecurityVersion version) at System.ServiceModel.WSHttpSecurity.CreateMessageSecurity(Boolean isReliableSessionEnabled, MessageSecurityVersion version) at System.ServiceModel.WSHttpBinding.CreateMessageSecurity() at System.ServiceModel.WSHttpBindingBase.CreateBindingElements() at System.ServiceModel.WSHttpBinding.CreateBindingElements() at System.ServiceModel.Channels.Binding.EnsureInvariants(String contractName) at System.ServiceModel.Description.ServiceEndpoint.EnsureInvariants() at System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint, Boolean useActiveAutoClose) at System.ServiceModel.ChannelFactory.CreateFactory() at System.ServiceModel.ChannelFactory.OnOpening() at System.ServiceModel.Channels.CommunicationObject.<System-ServiceModel-IAsyncCommunicationObject-OpenAsync>d__84.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at System.ServiceModel.Channels.CommunicationObject.<OpenAsyncInternal>d__83.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at System.Runtime.TaskHelpers.WaitForCompletion(Task task) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open() at System.ServiceModel.ChannelFactory.EnsureOpened() at System.ServiceModel.ChannelFactory1.CreateChannel(EndpointAddress address, Uri via) at System.ServiceModel.ChannelFactory1.CreateChannel() at System.ServiceModel.ClientBase1.CreateChannel() at System.ServiceModel.ClientBase1.CreateChannelInternal() at System.ServiceModel.ClientBase1.get_Channel()`

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create a Custom Binding Using the SecurityBindingElement
This topic demonstrates how to create a custom binding directly from individual binding elements and highlights some of the security ...
Read more >
c# - WCF .NET Core - create programmatically binding with ...
Omg, I found solution for this! My code for using MTOM and ClientCertificate: var tempBinding = new WSHttpBinding(); tempBinding.
Read more >
Using CoreWCF to Move WCF Services to .NET Core
The bindings that control the way that services are exposed could be specified in code, but more commonly was done through configuration. The ......
Read more >
How to Create SOAP Services with ASP.NET Core
Learn how to consume a WCF SOAP service from your .NET Core application. Understand how to create and host a SOAP service with...
Read more >
Modernizing legacy WCF applications to CoreWCF using ...
Review the configuration for porting, and click Port to start porting your solution to CoreWCF. Note: In Version 1.6, the porting assistant only ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found