Freigeben über


Binary Http Binding

Do I need IIS7 to use binary with HTTP for WCF?

No, all you need is a custom binding because we don’t include a standard binding with that configuration out of the box.

Here’s a quick example of putting binary and HTTP together with either code or configuration:

 BinaryMessageEncodingBindingElement encoding = new BinaryMessageEncodingBindingElement();
HttpTransportBindingElement transport = new HttpTransportBindingElement();
Binding binding = new CustomBinding(encoding, transport);
 <bindings>
<customBinding>
<binding name="BinaryHttpBinding">
<binaryMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>

You could also make a subclass of Binding if you didn’t want to build a custom binding every time, but no special version of IIS is required.

Comments

  • Anonymous
    July 13, 2009
    How do we make use of Windows Integrated Authentication with the new binaryMessageEncoding? I have not been able to get this to work. In SL2, we could use the basicHttpBinding with security mode set to "TransportCredentialOnly" and the transport clientCredentialType set to "Windows", and then we had the context of the windows user passed to the service. I would like to know how to do that with a BinaryMessageEncoding. Thanks!

  • Anonymous
    July 14, 2009
    Hi William, Thanks for the report.  I'm following up with the Silverlight team to see if there are any known issues or steps needed to get binary working with Windows auth.

  • Anonymous
    July 22, 2009
    Steve W wrote in to say: I had the same issue trying to get binary http encoding working with windows authentication and silverlight 3 - in the end it turns out to be fairly easy to solve - the config required is something like this: <bindings>        <customBinding>                <binding name="HttpBinaryBinding">                        <binaryMessageEncoding />                        <httpTransport authenticationScheme="Negotiate" />                </binding>        </customBinding> </bindings> <behaviors>        <serviceBehaviors>                <behavior name="default">                        <serviceAuthorization impersonateCallerForAllOperations="false" />                        <serviceDebug includeExceptionDetailInFaults="true" />                </behavior>        </serviceBehaviors> </behaviors> <services>        <service behaviorConfiguration="default" name="Surveys.Services.SurveyService">                <endpoint address="" binding="customBinding" name="SurveyServiceBinaryHttpEndpoint" bindingConfiguration="HttpBinaryBinding" contract="Surveys.Services.ISurveyService" />        </service> </services> The key is simply to use authenticationScheme="Negotiate" (or presumably something more specific) in the binding rather than trying to use the <security> element in the binding.