2012-04-09 21 views
1

Ich habe einen WCF-Dienst, der HTTPS für die Kommunikation und JSON für das Antwortformat verwendet. Ich möchte nicht, dass meine Methoden für irgendjemand verfügbar sind, also ändere ich die Authentifizierung in IIS von anonymen & grundlegenden zu nur grundlegendem.WCF-Authentifizierung über HTTPS

Bisher ist der Browser für Benutzer zu fragen und übergeben, aber ich erhalte die folgenden Fehler:

kann nicht eine Basisadresse finden, die mit der Bindung WebHttpBinding Schema http für den Endpunkt übereinstimmt. Registrierte Basisadressenschemas sind [https].

Was muss ich an meinem Endpunkt ändern, um mit der Authentifizierung arbeiten zu können?

Meine web.config wie folgt aussieht:

<?xml version="1.0"?> 
<configuration> 
    <system.web> 
    <compilation debug="false" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <bindings> 
     <webHttpBinding> 
     <binding name="restBinding"> 
      <security mode="TransportCredentialOnly"> 
      <transport clientCredentialType="Basic" proxyCredentialType="Basic" /> 
      </security> 
     </binding> 
     </webHttpBinding> 
    </bindings> 
    <services> 
     <service name="ContactLibrarySecure.ContactLibraryService"> 
     <endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration="" 
      name="mex" contract="IMetadataExchange" /> 
     <endpoint address="rest" behaviorConfiguration="restBehavior" 
      binding="webHttpBinding" bindingConfiguration="restBinding" 
      name="rest" contract="ContactLibrarySecure.IContact" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="https://192.168.1.31/ContactLibrary2.0HTTPS" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="restBehavior"> 
      <webHttp /> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name=""> 
      <serviceMetadata httpsGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 

</configuration> 

Antwort

1
<?xml version="1.0"?> 
<configuration> 
    <system.web> 
    <compilation debug="false" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="soapBinding" maxBufferSize="2000000000" maxBufferPoolSize="2000000000" 
      maxReceivedMessageSize="2000000000"> 
      <security mode="Transport"> 
      <transport clientCredentialType="Windows" proxyCredentialType="Basic" /> 
      <message clientCredentialType="UserName" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
     <wsHttpBinding> 
     <binding name="mexBinding"> 
      <security mode="Transport"> 
      <transport clientCredentialType="Windows" /> 
      <message clientCredentialType="UserName" /> 
      </security> 
     </binding> 
     </wsHttpBinding> 
     <webHttpBinding> 
     <binding name="restBinding" closeTimeout="00:10:00" sendTimeout="00:10:00" 
      maxBufferSize="2000000000" maxBufferPoolSize="2000000000" maxReceivedMessageSize="2000000000"> 
      <security mode="Transport"> 
      <transport clientCredentialType="Windows" /> 
      </security> 
     </binding> 
     </webHttpBinding> 
    </bindings> 
    <services> 
     <service name="ContactLibrarySecure.ContactLibraryService"> 
     <endpoint address="mex" binding="wsHttpBinding" bindingConfiguration="mexBinding" 
      name="mex" contract="IMetadataExchange" /> 
     <endpoint address="rest" behaviorConfiguration="restBehavior" 
      binding="webHttpBinding" bindingConfiguration="restBinding" 
      name="rest" contract="ContactLibrarySecure.IContact" /> 
     <endpoint address="soap" behaviorConfiguration="soapBehavior" 
      binding="basicHttpBinding" bindingConfiguration="soapBinding" 
      name="soap" contract="ContactLibrarySecure.IContact" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="https://192.168.1.31/ContactLibrary2.0HTTPS" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="restBehavior"> 
      <webHttp /> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
     </behavior> 
     <behavior name="soapBehavior"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name=""> 
      <serviceMetadata httpsGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 

</configuration> 

Diese Konfigurationsdatei mein Problem gelöst. Ich änderte von der grundlegenden zu Windows-Authentifizierung, nachdem ich Windows-Authentifizierung in IIS installiert.