Home > C#, WCF > A few tips when you want to develop a WCF service with streamed transfer mode

A few tips when you want to develop a WCF service with streamed transfer mode

This weekend I tried to develop a WCF service that uses the streamed transfer mode. Configuring this is very easy; you only have the change the “transferMode” property of the binding to Streamed (or StreamedResponse or StreamedRequest)

<system.serviceModel>
  <services>
    <service name="StreamingService.Upload">
      <endpoint address=""
                binding="basicHttpBinding"
                bindingConfiguration="streamingBinding"
                contract="StreamingService.IUpload"/>
    </service>
  </services>

  <bindings>
    <basicHttpBinding>
      <binding name="streamingBinding"
                transferMode="Streamed"/>
    </basicHttpBinding>
  </bindings>
</system.serviceModel>

Simple and straightforward, but while doing this I discovered a few attention points:

  • If want to use a http binding, you can only use the basicHttpBinding as the wsHttpBinding does not support the “transferMode” property.
  • If you want to test this. You cannot run this using the integrated web server of Visual Studio 2010. I continuously received bad request error messages “ProtocolException: The remote server returned an unexpected response: (400) Bad Request.”. It was only after I switched to IIS that my service worked.
  • The “transferMode” property is not part of the metadata for http bindings, so in case you do “Add Service Reference” in Visual Studio, you have to manually edit the app.config of web.config of your client application.

Not a big blog article this time, but I hope that you find it helpful. 🙂

Advertisements
Categories: C#, WCF
  1. red october
    February 24, 2012 at 16:12

    Hi Pieter,
    Indeed it is a big blog for me… I scratched my head over and over again trying to find the reason I was getting the Error 400 Bad request… After I moved my site to IIS, streaming started working… Thanks a mil…

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: