Protocol Channel Example: Chunking

In my quick PDC recap I promised to post Yasser’s demo code. So before I digress: here is the code for a protocol chunking channel.

There is a lot more refinement to be added in order to make this production-level, but it’s a great illustration of the power and flexibility of a layered channel model. We have streaming over some Indigo transports (TCP/Named Pipe datagram, and HTTP requests and responses). However, these streams suffer from connections getting dropped mid-message, and need to be secured, routed, etc at the transport layer.

Yasser’s chunking channel nicely sidesteps all of these issues. By fragmenting/reassembling at the SOAP layer, each SOAP “chunk message” can be secured using WS-Security, reliably sent using WS-RM, and even transacted using WS-Transactions. Even better, this solution works for streaming a Message over any arbitrary transport. Which means you can write a simple streaming media server by adapting the chunking channel and using it in conjunction with a Udp multicast transport. Maybe I’ll mock one up next week even :)

For those not on commnet, I’ve posted the slides from my PDC talk here. Enjoy!

7 Responses to “Protocol Channel Example: Chunking”

  1. kennyw.com » Blog Archive » Large Messages and WCF Says:

    […] Enable streaming on your binding (either through TransferMode.Streamed on a transport or by using chunking at the top of your binding stack) […]

  2. John Says:

    Hi Kenny.
    I’m writing a custom HTTP binding. Would you know if the following channel stack yields an IDuplexSessionChannel shape?
    ReliableSessionBindingElement
    TextMessageEncodingBindingElement
    HttpTransportBindingElement
    I’m implementing a WsHTTP custom binding for the chunking sample, but it fails with when I add the ChunkingBindingElement to the top of the BindingElementCollection. The error is “’WsHttpChunkingBinding’ doesn’t support creating any channel types”. The CanBuildChannelFactory and CanBuildChannelListener functions in ChunkingBindingElement always return false. I suspect the binding elements I have chosen for my test binding don’t support the IDuplexSessionChannel shape. I also get the same problem when I remove the ChunkingBindingElement and add a CompositeDuplexBindingElement element. Cheers.

  3. Kenny Says:

    In order to get duplex session from RM on top of HTTP you need to layer CompositeDuplex and OneWayBindingElement in between (see what WsDualHttpBinding generates for example). You can setup this binding stack for IDuplexSessionChannel over HTTP:
    ReliableSessionBindingElement
    CompositeDuplexBindingElement
    OneWayBindingElement
    TextMessageEncodingBindingElement
    HttpTransportBindingElement

  4. Guillaume Says:

    Hello Kenny,

    I’m trying to integrate ChunkingChannel with WsFederationHttpBinding.

    Is it my stack:

    …….

    But it fails. Is it possible to do what I would?

    Thanks in advance

  5. Kenny Says:

    Your stack seems to be ellided. is Chunking at the top? Is it a duplex stack?

  6. Ksenia Says:

    Hello Kenny,

    I have the same problem as guys had. I try to use chunking for WSDualHttpBinding. I create binding elements from in the following way:
    public override BindingElementCollection CreateBindingElements()
    {
    WSDualHttpBinding wsHttpBinding = new WSDualHttpBinding();
    BindingElementCollection beCollection = wsHttpBinding.CreateBindingElements();
    beCollection.Insert(6, be);
    return beCollection;

    //BindingElementCollection col = new BindingElementCollection();
    //col.Add(new TransactionFlowBindingElement());
    //col.Add(rsbe);
    ////col.Add(new TransportSecurityBindingElement());
    //col.Add(SecurityBindingElement.CreateAnonymousForCertificateBindingElement());
    //col.Add(cdbe);
    //col.Add(owbe);
    //col.Add(new WindowsStreamSecurityBindingElement());
    //col.Add(encbe);
    //col.Add(be);
    //col.Add(httpbe);
    //return col;
    }

  7. kennyw.com » Blog Archive » Security and Streamed Messages Says:

    […] you want to use full WS-Security, then you would need app-level “chunking” or a chunking protocol at the […]

Leave a Reply