0

I am trying to figure out how to convert the following basic http binding to a custom binding. The two bindings seem to have a vastly different schema.

  <basicHttpBinding>
    <binding name="MyBinding">
      <security mode="TransportWithMessageCredential">
        <message clientCredentialType="Certificate" />
      </security>
    </binding>
  </basicHttpBinding>
halfer
  • 19,824
  • 17
  • 99
  • 186
mark
  • 59,016
  • 79
  • 296
  • 580
  • Why are you trying to convert to a custom binding? Is there something in the out of the box basicHttpBinding that is missing for your needs? – Tim Sep 30 '15 at 18:40
  • Custom binary encoding that we want to apply. Custom binding lets us do it easily. – mark Sep 30 '15 at 18:59
  • Ah, ok - that makes sense. Hopefully my answer below can get you going in the right direction. – Tim Sep 30 '15 at 19:03

1 Answers1

2

It's not clear why you want to convert this to a custom binding - usually a custom binding is used when one of the out-of-the-box bindings does not meet the needs of the requirements.

A quick way to do this is to use Yaron Naveh's WCF BindingBox (found via this answer here on SO). Using the BindingBox with your supplied config yields the following:

<customBinding>
  <binding name="NewBinding0">
    <security authenticationMode="CertificateOverTransport"
               messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" 
              requireDerivedKeys="false" securityHeaderLayout="Lax" />
    <textMessageEncoding MessageVersion="Soap11" />
    <httpsTransport />
  </binding>
</customBinding>

When developing a custom binding, you need to keep in mind the following order of elements:

  1. TransactionFlow element (Optional)
  2. ReliableSession element (Optional)
  3. Security (Optional, can be Symmetric, Asymmetric, Transport-level)
  4. CompositeDuplex element (Optional)
  5. Transport upgrades (Optional, can be SSL stream, Windows stream, Peer Resolver)
  6. Text Encoding (Required, can be Text, Binary, MTOM, Custom)
  7. Transport (Required, can be TCP, Named Pipes, HTTP, HTTPS, flavors of MSMQ, Custom)

You can get more information from MSDN - CusotmBinding Class

EDIT Since you are using a custom binary encoding, you would change the <textMessageEncoding> element to <binarMessageEncoding MessageVersion="Soap11">.

Community
  • 1
  • 1
Tim
  • 28,212
  • 8
  • 63
  • 76
  • I am standing dazzled at the value of the `messageSecurityVersion` attribute. I will have to test the answer, but +1 already for the WCF BindingBox. – mark Sep 30 '15 at 19:15
  • Great - happy coding :) – Tim Sep 30 '15 at 19:35