Saturday, August 22, 2009

BindingBox: Convert WCF Bindings

@YaronNaveh



The WCF BindingBox is here!

What is it?
BindingBox is an online application that converts WCF bindings to a customBinding configuration.

Why we need it?
WCF bindings capture a general use case and allow us to customize it. For example, basicHttpBinding is good for interoperability with older soap stacks while WSHttpBinding fits WS-* based communication. However, there are cases where we can not use the out of the box bindings. For example:

  • We want to further customize the binding behind what it exposes. For example, we might want WSHttpBinding not to send a timestamp (for interoperability reasons) but this is not a built in option.

  • We have a special use case which is not captured by any of the out-of-the-box bindings. For example, we want to use binary encoding over http.

    In such cases we need to convert our binding into a custom binding. This is not a trivial process. In particular, some security settings can be very frustrating to translate.

    For this reason I have written the WCF BindingBox. This is an online application which automatically converts any binding to a customBinding.



    How to use it - Tutorial

    Step 1 - Get your current binding

    Just open your web.config or app.config file and navigate to the "<bindings>" element. Then copy its content to the clipboard. Be sure to copy the wrapping "<bindings>" element as well:


    <bindings>
       <wsHttpBinding>
         <binding name="MyBinding">
           <security>
            <message clientCredentialType="UserName" />
           </security>
         </binding>
        </wsHttpBinding>
    </bindings>


    Step 2 - Convert your binding

    Just navigate to the BindingBox and paste your binding from step 1. Then click on the "Convert to CustomBinding" button and copy to the clipboard your new binding. It may look like this:


    <customBinding>
       <binding name="NewBinding0">
         <transactionFlow />
         <security authenticationMode="SecureConversation" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
           <secureConversationBootstrap authenticationMode="UserNameForSslNegotiated" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" />
         </security>
         <textMessageEncoding />
         <httpTransport />
       </binding>
    </customBinding>


    Step 3 - Use the custom binding

    Basically, you now just need to use the BindingBox result as your binding configuration.

    In practice you would do it in one of the following ways:

  • In your .config file manually configure your endpoint to use a custom binding and set its configuration.
  • Use the WCF configuration editor to configure your endpoint to use a CustomBinding. then in your .config override the default customBinding configuraiton with the BindingBox result.


    Currently supported bindings

    BindingBox currently supports these bindings:

  • WSHttpBinding
  • WS2007HttpBinding
  • BasicHttpBinding


    More to follow

    Stay tuned for these:

  • NetTcpBinding
  • NetNamedPipeBinding
  • WSFederationHttpBinding
  • WS2007FederationHttpBinding


    Known issues

  • DefaultAlgorithmSuite is not converted
  • ReaderQuotas are not converted

    Please report any bug you find. Also feel free to submit an enhancement request.

    There is also a nice story behind BindingBox: It uses cutting edge technologies such as Windows Azure and MEF. More to come on this...

    @YaronNaveh

    What's next? get this blog rss updates or register for mail updates!
  • 19 comments:

    Tamir said...
    This comment has been removed by the author.
    Anonymous said...

    Looks very nice :-)

    Moshe said...

    Why don't you expose it as an API (and not only GUI application)? It would be very useful for automated consumers.

    Yaron Naveh said...

    Moshe

    I'll consider adding it to future version...

    Anonymous said...

    Thank you, Thank you, Thank you!!!

    I've been struggling with converting my basicHttpBinding to a custom binding for hours and hours, but your BindingBox saved the day! :)

    Any chance of posting the source for this?

    Yaron Naveh said...

    I'll consider do it sometime soon. My Azure trial will be over pretty soon anyway so the site is expected to go down :(

    Anonymous said...

    Yaron: This is great! You have done a very nice service to the development community. Thank you!

    Kiquenet said...

    will be opensource in codeplex ?? thx, it's great !!

    Anonymous said...

    Would be nice if it worked. My basicHttpBinding loses everything when converted.

    Yaron Naveh (MVP) said...

    Anonymous

    please share your binding here.

    John said...

    Using Fiddler2, I could not see the difference between WSHttpBinding and the generated custom binding using your binding box. How can I make this custom binding consumable by a Java client? This is because I have a hard time to make the service consumable if it is in WSHttpBinding.

    Yaron Naveh (MVP) said...

    John

    Possibly CUB was not configured correctly. Use the built-in CUB sample with Fiddler (e.g. override client url to http://localhost:8888/) and see.

    Krishna Tejaswi Chandrapatla said...

    Hello,
    Can you please help me out in converting below ones into custom binding

    Yaron Naveh (MVP) said...

    Krishna

    Please mail me your binding

    Anonymous said...

    This is a wonderful tool I have a questions for you though. I am using a x509 certificate. I converted the binding from a wsHttpBinding so I could use the maxClockSkew functionality. I now get Keyset Does not Exist errors. but when I sub my wsHttpBinding back in it works fine. Do you have any thoughts on this. Thanks

    Yaron Naveh (MVP) said...

    please send me the *full* app.config before and after the change.

    Typically this is related to the x.509 certificate setting, which is not in the binding setting at all.

    James McLachlan said...

    Very happy to have found this early in my quest to transform a configuration into a custom binding. I'm sure you saved me a lot of time. Thanks so much!

    CodeMonkey said...

    Hi - do you have plans to support nettcpbinding?

    I just want the basics




    Yaron Naveh (MVP) said...

    no current plans but you should be good w something like

    binaryMessageEncoding windowsStreamSecurity
    tcpTransport

    just look at NetTcpBinding ctor for more details