I have the following CustomeBinding in a WCF's Web.config file
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="notSecureBinding">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
<binding name="SecureBinding">
<textMessageEncoding messageVersion="Soap12" />
<httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://ServerName.myDomain.org/ADSearcher/Service1.svc"
binding="notSecureBinding"
bindingConfiguration="notSecureBinding"
contract="myNamespace.Contract1"
name="notSecureBinding" />
<endpoint address="http://ServerName.myDomain.org/ADSearcher/Service1.svc"
binding="SecureBinding"
bindingConfiguration="SecureBinding"
contract="myNamespace.Contract1"
name="SecureBinding" />
</client>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Notice that i'm explicitly setting the messageVersion to Soap12, but when i call the service in the code below, i get an error message which seems to suggest that the service expects Soap11, which i'm finding strange.
This is the code
HttpTransportBindingElement httpTransport = new HttpTransportBindingElement() { MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue };
TextMessageEncodingBindingElement TextMessage = new TextMessageEncodingBindingElement() { MessageVersion = System.ServiceModel.Channels.MessageVersion.Soap12 };
CustomBinding customBinding = new CustomBinding(TextMessage, httpTransport);
EndpointAddress endpointAddress = new EndpointAddress("http://ServerName.myDomain.org/ADSearcher/Service1.svc");
IService1 ADUser = new ChannelFactory<IService1>(customBinding, endpointAddress).CreateChannel();
DataTable dt = ADUser.GetUserList(strUserName, strFirstName, strLastName, strEmail, domain);
if i i call the above code with "MessageVersion.Soap12" i get the below error
Content Type application/soap+xml; charset=utf-8 was sent to a service expecting text/xml; charset=utf-8. The client and service bindings may be mismatched.
But if i set the MessageVersion to "MessageVersion.Soap11" (which now differs from Soap11 that i have the web.config binding), the code is executed successfully with out any mismatch.
I'm not understanding why. MY preference is to to use MessageVersion.Soap12 with https support.