2012-02-10 79 views
1

我正在嘗試使用WCF安全令牌服務網站模板創建一個虛擬安全令牌服務。當創建網站時,如果我指定一個文件系統URI並在ASP.NET開發Web服務器中託管該站點,那麼一切似乎都沒有問題。但是,我希望STS使用SSL,並且還希望避免使用由ASP.NET Development Web Server分配的動態端口時出現的跨域問題。因此,我重新創建了相同的網站,但在IIS 7.5中爲預配置的Web應用程序指定了HTTPS URI(例如https://localhost/SecurityTokenService/),而不是文件系統URI。現在,所有嘗試導航到Service.svc文件都會導致強制連接重置。聯繫在IIS 7.5中託管的WCF服務時重置連接

下面是我的web.config文件,雖然它在ASP.NET開發Web服務器中託管的事實讓我覺得問題出在IIS設置上。我可能會嘗試弄清楚發生了什麼事情?

<?xml version="1.0" encoding="UTF-8"?> 
    <configuration> 
     <configSections> 
      <section name="microsoft.identityModel" type="Microsoft.IdentityModel.Configuration.MicrosoftIdentityModelSection, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> 
     </configSections> 
     <appSettings> 
      <add key="IssuerName" value="ActiveSTS"/> 
      <add key="SigningCertificateName" value="CN=STSTestCert"/> 
      <add key="EncryptingCertificateName" value=""/> 
     </appSettings> 
     <connectionStrings /> 
     <location path="FederationMetadata"> 
      <system.web> 
       <authorization> 
        <allow users="*"/> 
       </authorization> 
      </system.web> 
     </location> 
     <system.web> 
      <compilation debug="true" targetFramework="4.0"> 
       <assemblies> 
        <add assembly="Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
       </assemblies> 
      </compilation> 
      <authentication mode="None"/> 
      <pages> 
       <controls> 
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
       </controls> 
      </pages> 
     </system.web> 
     <system.web.extensions> 
      <scripting> 
       <webServices> 
       </webServices> 
      </scripting> 
     </system.web.extensions> 
     <system.serviceModel> 
      <services> 
       <service name="Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceContract" behaviorConfiguration="ServiceBehavior"> 
        <endpoint address="https://localhost/SecurityTokenService/Service.svc/IWSTrust13" binding="ws2007HttpBinding" contract="Microsoft.IdentityModel.Protocols.WSTrust.IWSTrust13SyncContract" bindingConfiguration="ws2007HttpBindingConfiguration"/> 
        <host> 
         <baseAddresses> 
          <add baseAddress="http://localhost/SecurityTokenService/Service.svc" /> 
         </baseAddresses> 
        </host> 
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
       </service> 
      </services> 
     <bindings> 
      <ws2007HttpBinding> 
       <binding name="ws2007HttpBindingConfiguration"> 
        <security mode="TransportWithMessageCredential"> 
         <message establishSecurityContext="false" clientCredentialType="UserName" /> 
        </security> 
       </binding> 
      </ws2007HttpBinding> 
     </bindings> 
     <behaviors> 
      <serviceBehaviors> 
       <behavior name="ServiceBehavior"> 
        <serviceMetadata httpGetEnabled="true" /> 
        <serviceDebug includeExceptionDetailInFaults="false" /> 
       </behavior> 
      </serviceBehaviors> 
     </behaviors> 
    </system.serviceModel> 
    <microsoft.identityModel> 
     <service> 
      <securityTokenHandlers> 
       <remove type="Microsoft.IdentityModel.Tokens.WindowsUserNameSecurityTokenHandler, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
       <add type="CustomUserNamePasswordTokenHandler, App_Code"/> 
      </securityTokenHandlers> 
     </service> 
    </microsoft.identityModel> 
</configuration> 

更新:我可以導航到Web應用程序中的其他文件。只是不是* .svc文件。除了101 statuc代碼之外,我沒有任何工作要做,所以這很令人沮喪。

更新:進一步的實驗表明,問題只存在於STS和託管在IIS中的WCF服務。如果我在IIS中託管常規WCF服務,則沒有問題。我下載了各種包含自定義STS的示例項目,並且它們都表現出相同的行爲。這使我相信我的IIS的配置存在問題,導致它無法與STS一起玩。打我,我怎麼可能找出問題所在......

回答

0

我與微軟就此開了一個支持案例。在深入瞭解大量日誌和跟蹤文件後,我們確定IIS中虛擬目錄的物理路徑不正確。這很奇怪,因爲當我將項目添加到我的解決方案時,Visual Studio代表我創建了虛擬目錄。我手動刪除並重新創建虛擬目錄,一切開始工作。

0

您服務中的基地址配置爲HTTP而非HTTPS。另外,如果您使用HTTPS瀏覽它並期望看到服務定義,我認爲您需要httpsGetEnabled而不是httpGetEnabled。這些會成爲問題嗎?

+0

我將我的web.config文件與Windows Identity Training Kit中的一個進行了比較,我沒有看到任何明顯的差異。只是爲了咧嘴笑,我嘗試了你推薦的改變,而且我仍然得到相同的行爲。不過謝謝你的建議。 – 2012-02-10 21:46:38