Forum Cross Platform with Xamarin

WCF BasicHttpBinding with TransportWithMessageCredential (UserName) failure (iOS and Android)

brhlavinkabrhlavinka USMember

We have a service deployed over HTTPS that can be connected to via BasicHttpBinding. A console application can successfully connect to the service:

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

var credentials = new ClientCredentials();
credentials.UserName.UserName = username;
credentials.UserName.Password = password;

var service = new SecureServiceClient(
        new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential),
        new EndpointAddress(""));

var defaultCredentials = service.Endpoint.Behaviors.Find<ClientCredentials>();

return service;

Using the same code in our Xamarin application causes unexpected behavior:

  • Android: System.TypeLoadException: Could not load type 'System.ServiceModel.HttpTransportSecurity' from assembly 'System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

  • iOS: System.ServiceModel.FaultException: An error occurred when verifying security for the message.

  • iOS: Further investigation of error messages on the server showed this - MessageSecurityException: Security processor was unable to find a security header in the message. This might be because the message is an unsecured fault or because there is a binding mismatch between the communicating parties. This can occur if the service is configured for security and the client is not using security.

Can anyone provide any ideas on a fix? (We are using the most recent version of Xamarin for both iOS and Android)


Sign In or Register to comment.