Search code examples
wcfwcf-bindingcustom-binding

How to set up bindings in webconfig to enable streaming in RESTful WCF service


I have a RESTful service which I'm trying to enable to accept a PDF file. I'm using a stream to transport it, but I keep running into mysterious errors in the process.

My first error is this: Security negotiation failed because the remote party did not send back a reply in a timely manner. This may be because the underlying transport connection was aborted.

Not sure what's causing that. Also, I tried adding a customBinding in an attempt to fix this error, and I get an error that says I don't have my binding set up properly.

My main, overall question is this: Does anyone know of a simple binding and complete instructions for how to set it up to enable streaming?


Solution

  • I managed to get it working. I found that my problem wasn't my binding, but that it was never registered. Here's the code in the web.config file:

    <services>
        <service name="ResearchUploadService.Service1" behaviorConfiguration="ResearchUploadService.Service1Behavior">
        <endpoint address="" binding="customBinding" bindingConfiguration="basicConfig" contract="ResearchUploadService.IService1"/>            
        </service>
    </services>
    ...
    <bindings>
        <customBinding>
            <binding name="basicConfig">
               <binaryMessageEncoding/>
               <httpTransport transferMode="Streamed" maxReceivedMessageSize="67108864"/>
            </binding>
         </customBinding>
    </bindings>