WCF: Using Streaming and Username/Password authentication at the same time

Posted by Kay on Stack Overflow See other posts from Stack Overflow or by Kay
Published on 2010-03-02T13:33:13Z Indexed on 2010/04/12 1:13 UTC
Read the original article Hit count: 1205

Filed under:
|
|
|

Hi,

I have a WCF Service with the following requirements: a) The client requests a file from the server which is transferred as a Stream. Files may be 100MB or larger. I need streaming or chucking or whatever to make sure that IIS is not loading the whole package into memory before starting to send it. b) The client will transfer an ID to identify the file to be downloaded. The user should be authenticated by providing username/password. c) While the username/password part of the communication needs to be encrypted, encryption of the downloaded file is optional for our use case.

My other services, where I am returning smaller files, I am using the following binding:

<ws2007HttpBinding>
    <binding name="ws2007HttpExtern" maxReceivedMessageSize="65536000">
      <security mode="Message">
        <message clientCredentialType="UserName" />
      </security>
    </binding>        
  </ws2007HttpBinding>

But, as I said, that is no good for streaming (Message encryption needs the complete message to encrypt and that is not the case when streaming).

So, I asked Microsoft support and I got more or less the following proposal:

<bindings>
  <basicHttpBinding>
    <binding name="basicStreaming" 
      messageEncoding="Mtom" transferMode="StreamedResponse">
      <security mode="Transport">
        <transport clientCredentialType="Basic" />
      </security>
    </binding>
</bindings>

<services>
  <service behaviorConfiguration="MyProject.WCFInterface.DownloadBehavior"
    name="MyProject.WCFInterface.DownloadFile">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicStreaming"
      contract="MyProject.WCFInterface.IDownloadFile" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>    
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="MyProject.WCFInterface.DownloadBehavior">
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

When I use this, I get the following error message:

Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding. Registered base address schemes are [http].

I am using the Web Development Server so far (for production IIS7).

I have two questions. a) How would you configure WCF to achieve the goal? b) If the MS proposal is good: What I am doing wrong, the error message does not really help me.

Thanks.

© Stack Overflow or respective owner

Related posts about wcf

Related posts about streaming