Over a million developers have joined DZone.

WCF Binary Bindings in Silverlight 3


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

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

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.



Published at DZone with permission of John Papa. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}