Mike
Mike

Reputation: 1738

2 basicHttpBindings for WCF service

I am trying to set up a service with 2 different basicHttpBinding configurations. I know I will have to create separate endpoints for them (which is no problem). The goal is to have 1 basicHttpBinding endpoint that is configured to use Windows Auth (our company default), and one basicHttpBinding endpoint configured to use basic http auth. Here is one binding configuration:

  <!-- Normal configuration with Windows Auth -->
  <basicHttpBinding>
    <binding maxBufferPoolSize="4194304" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows" />
      </security>
    </binding>
  </basicHttpBinding>

and here is the second configuration:

<!-- Configuration with basic authentication -->
  <basicHttpBinding>
    <binding maxBufferPoolSize="4194304" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Basic" />
      </security>
    </binding>
  </basicHttpBinding>

is there a name property or something I can use to differentiate between the two?

Upvotes: 0

Views: 66

Answers (1)

Seymour
Seymour

Reputation: 7067

In the WCF configuration specify a unique name for each binding and then reference the binding name in the service endpoint sections. The following snippet provides a simple example:

<bindings>
  <basicHttpBinding>
    <binding name="basicHttpBindingWindowsCredential"  ... >
      ...
    </binding>
    <binding name="basicHttpBindingBasicCredential"  ... >
      ...
    </binding>

<services>
  <service ... >
    <endpoint ... binding="basicHttpBinding" bindingConfiguration="basicHttpBindingWindowsCredential" >
    <endpoint ... binding="basicHttpBinding" bindingConfiguration="basicHttpBindingBasicCredential" >

Upvotes: 1

Related Questions