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. 🙂