I have a WCF service with the following binding:
<basicHttpBinding>
<binding name="bind" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message algorithmSuite="Default" clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
I am consuming it dynamically in code with this endpoint:
BasicHttpBinding binding = new BasicHttpBinding();
binding.Name = "bind";
binding.MaxBufferSize = int.MaxValue;
binding.MaxReceivedMessageSize = int.MaxValue;
ServiceEndpoint endPoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(ImyContract)), binding, new EndpointAddress(endPointAddress));
endPoint.Name = name;
ChannelFactory<ImyContract> channelFactory = new ChannelFactory<ImyContract>(endPoint);
When I browse to the service everything works exactly as expected, however when connecting through the application I get:
Content Type text/xml; charset=utf-8 was not supported by service http://localhost/SynchronizationService/SyncService.svc/DataBinding. The client and service bindings may be mismatched.
I understand this error is caused often because basicHttpBinding using SOAP 1.1 and wsHttpBinding uses 1.2, however, I am not using SSL on the server, and have another endpoint using streaming, so switching is not an option for me. What am I doing wrong that is prevening me from consuming the service correctly?
UPDATE:
Also, I am not using the default basicHttpBinding on the client, but setting security to match what the server is expecting. I am setting the security with this method:
private static BasicHttpSecurity SetEndpointSecurity()
{
BasicHttpSecurity security = new BasicHttpSecurity();
HttpTransportSecurity transport = new HttpTransportSecurity();
BasicHttpMessageSecurity message = new BasicHttpMessageSecurity();
security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
transport.ClientCredentialType = HttpClientCredentialType.Windows;
transport.ProxyCredentialType = HttpProxyCredentialType.None;
transport.Realm = "";
message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
security.Transport = transport;
security.Message = message;
return security;
}