2012-04-09 116 views
1

我有一個WCF服務使用https進行通信,json用於響應格式。我不希望我的方法對任何人都可用,所以我將IIS中的身份驗證從基本的匿名&更改爲基本。通過https進行WCF驗證

到目前爲止,瀏覽器要求用戶並通過,但我得到了以下錯誤:

找不到與綁定的WebHttpBinding端點符合計劃http的基址。註冊的基地址方案是[https]。

我必須改變我的端點以使用身份驗證嗎?

我的web.config看起來像:

<?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> 

回答

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> 

這個配置文件解決我的問題。在iis中安裝了Windows身份驗證後,我從基本更改爲Windows身份驗證。

相關問題