One of the most common comments I hear form people when they start digging into Silverlight 3 Beta (and Silverlight 2) is the lack of WCF binding options. Some changes have been made to include binary encoding in Silverlight 3, so now we have:

  • customBinding
    • can do things like binary binding with WCF clients
    • new to Silverlight 3 Beta
  • basicHttpBinding
    • basic clear text binding
  • pollingDuplexHttpBinding
    • exactly what it says … a pseudo duplex basic binding that uses polling

 

Custom binding with binary encoding is nice if you want to do binary encoding of the message. In fact, this is the default binding that is created when you use a Silverlight enabled WCF file template in Visual Studio 2008 to create a WCF service. Binary encoding often offers performance gains over text encoding. Here is a quick glimpse at the config setup for the binding

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name="SilverlightApplication2.Web.Service1Behavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <customBinding>
            <binding name="customBinding0">
                <binaryMessageEncoding />
                <httpTransport />
            </binding>
        </customBinding>
    </bindings>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <services>
        <service behaviorConfiguration="SilverlightApplication2.Web.Service1Behavior"
            name="SilverlightApplication2.Web.Service1">
            <endpoint address="" binding="customBinding" bindingConfiguration="customBinding0"
                contract="SilverlightApplication2.Web.Service1" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
    </services>
</system.serviceModel>

 

There is a nice blog post from Yavor Georgiev, (Program Manager on the Connected Framework Team) that explains this in more detail. You can also view Eugene Ovosvetsky’s (also of Microsoft) presenting his Consuming Web Services in Silverlight 3 session at Mix 2009 … this session covers binary encoding as well as other new networking features.