2012-07-16 47 views
1

我一直在我可能找到的任何地方(包括這裏在Stackoverflow)上搜索,以找出一個錯誤,我試圖將WCF服務部署到Windows 7 x64上的IIS 7.5上,該服務僅通過帶有基本HTTP身份驗證的SSL運行。我在IIS中有一個站點,它具有綁定到端口50443的HTTPS和自簽名證書。 (我不能使用標準端口443,因爲我們計劃在已經運行Tomcat這是在80和443監聽服務器上部署這IIS)HTTPS上的WCF生成「提供的URI方案'https'無效;期望'http'。」

這是在web.config:

<configuration> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <serviceMetadata httpsGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="SSLBinding"> 
      <security mode="TransportCredentialOnly"> 
      <transport clientCredentialType="Basic"/> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <services> 
     <service name="HelloWorldWcf.HelloWorldWcfService"> 
     <endpoint name="HelloWorldWcf.HelloWorldWcfService" 
        address="https://mylaptop:50443/HelloWorld/Service1.svc" 
        binding="basicHttpBinding" 
        bindingConfiguration="SSLBinding" 
        contract="HelloWorldWcf.IHelloWorldWcfService"/> 
     <endpoint address="https://mylaptop:50443/HelloWorld/Service1.svc/mex" 
        binding="mexHttpsBinding" 
        contract="IMetadataExchange"/> 
     </service> 
    </services> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
</configuration> 

如果我手動瀏覽到服務端點地址並輸入基本身份驗證憑據,我得到了我的瀏覽器中顯示以下異常錯誤信息:

The provided URI scheme 'https' is invalid; expected 'http'.
Parameter name: context.ListenUriBaseAddress

這是我得到嘗試運行同樣的錯誤WCF客戶端針對類似的服務,除了它以「Parameter name:via」結尾(因爲調用堆棧中顯示的方法的參數名稱「System.ServiceModel.Channels.TransportChannelFactory`1.ValidateScheme(URI via)」實際上是「via」)。

我已經調整了服務器和客戶端配置文件很多次,我失去了軌道,但上面的web.config文件是我迄今爲止最好的猜測 - 它甚至不能從瀏覽器工作,很多少一個WCF客戶端。

通過基於HTTPS的HTTP身份驗證,在非標準SSL端口上訪問託管在IIS 7.5中的WCF服務需要做什麼?幫幫我! (&謝謝!)

回答

4

嘗試將它添加到綁定

<security mode="Transport"> 
    <transport clientCredentialType="None" proxyCredentialType="None" realm=""/> 
    <message clientCredentialType="Certificate" algorithmSuite="Default" /> 
</security> 
+0

每當我嘗試使用mode =「Transport」時,出現此錯誤:「此服務的安全設置需要'匿名'身份驗證,但未啓用承載此服務的IIS應用程序。」你知道它指的是什麼「安全設置」嗎?如果我改變你的建議,以便除了回到mode =「TransportCredentialOnly」之外,所有內容都是相同的,我會得到最初報告的錯誤。謝謝! – ALEXintlsos 2012-07-17 14:53:18

3

Arrrrgh!好了,剩下的步驟,以得到它的工作:

  1. 替換我<安全>節點與burning_LEGION的web.config中。

  2. 消除web.config中的「mex」端點。 (這可以讓我在瀏覽器中使用通常的「你已經創建了服務」的友好網頁。)

  3. 轉義「DOMAIN \ username」字符串中的反斜槓我分配給HelloWorldWcfServiceClient.ClientCredentials.UserName。客戶端C#代碼中的UserName。 (難道我說「arrrrgh!」人,是我的臉都紅了?)。這消除了我的步驟1和2之後得到了錯誤:

System.ServiceModel.Security.MessageSecurityException: "The HTTP request is unauthorized with client authentication scheme 'Basic'. The authentication header received from the server was 'Basic realm="mylaptop"'.---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.

我得到了第2步的想法來自here這使我認爲mex對HTTPS不滿意,對於步驟3中的here,我注意到用戶名是@「domain \ username」,而不是「domain \ username」。

+1 to burning_LEGION for the assist!

因此,未解決的問題:(1)爲什麼安全/消息節點對不使用消息安全性(僅傳輸安全性)的配置有影響? (2)如果mex端點干擾正常操作,它有什麼意義? (3)如果mode =「TransportCredentialOnly」不適用於HTTPS,爲什麼我不會收到錯誤指示?

相關問題