Cannot expose two endpoints for one WCF service

Viewed 331

I'm trying to set up a WCF service with two endpoints which both expose the same service contract as follows

What I want to be exposed to clients...

http://server:1955/myService/secondEndpoint and https://server:443/myService/

The issue appears to be with multiple base addresses.

If I explicitly specify the full address in each endpoint and omit the baseAddress section I get the following error

"When 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' is set to true in configuration, the endpoints are required to specify a relative address. If you are specifying a relative listen URI on the endpoint, then the address can be absolute. To fix this problem, specify a relative uri for endpoint 'http://server:1955/myService/secondEndpoint'."

I therefore put relative address in the endpoint and add a base address

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

I feel like I am going in circles with this. Any help much appreciated.

  <system.serviceModel> 
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBindingConfiguration" 
                 maxBufferPoolSize="2147483647" 
                 maxBufferSize="2147483647" 
                 maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" 
                        maxStringContentLength="2147483647" 
                        maxArrayLength="2147483647" 
                        maxBytesPerRead="2147483647" 
                        maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>
      <wsHttpBinding>
        <binding name="wsHttpBindingConfiguration" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
         <readerQuotas maxDepth="2147483647"
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
         <security mode="Transport" >
          <transport clientCredentialType="Windows"   />
         </security>
        </binding>
      </wsHttpBinding>  
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>  
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <services>
      <service behaviorConfiguration="ServiceBehavior" name="myService">
        <endpoint address="nonsecure" 
                  binding="basicHttpBinding" 
                  bindingConfiguration="basicHttpBindingConfiguration" 
                  contract="ImyService" 
                  name="myService" />
        <endpoint address="https://server:443/myService.svc"
                  binding="wsHttpBinding"
                  bindingConfiguration="wsHttpBindingConfiguration"
                  contract="ImyService"
                  name="myService" />
        <host>
          <baseAddresses>
            <add baseAddress="http://server:1955/myService/" />
            <add baseAddress="https://server:443/myService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>
0 Answers
Related