2011-09-21 75 views
6

平臺WCF服務失敗並返回一個整數。我還創建了一個小型ASP.NET Web應用程序來測試該服務。測試Web應用程序只有一個包含字段和按鈕的頁面,單擊該按鈕實際上會調用Web服務以插入數據並返回一個整數值。認證,同時呼籲從ASP.NET

的步驟我把:

  • 構建WCF服務
  • 發佈WCF服務
  • 生成代理類(的.cs)和使用的app.config SvcUtil工具
  • 構建測試ASP .net應用程序並添加上述步驟中生成的代理類和配置設置。
  • 三絕測試程序

它正常工作時,我同時部署WCF和我的電腦上測試Web應用程序 - Windows XP中,IIS 5.1。但是,每當我試圖將它們部署在遠程服務器上時,它都不起作用。當我試圖使用該服務(部署遠程服務器上 - 在Windows 2003服務器,IIS 6)我收到以下錯誤:

The request for security token could not be satisfied because authentication failed.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ServiceModel.FaultException: The request for security token could not be satisfied because authentication failed.

以下是.config文件內容:

調用ASP.NET Web應用程序的Web.config(消費者)的WCF節:週轉基金的

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
    <binding name="WSHttpBinding_IMyWCFService" closeTimeout="00:01:00" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
     bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
     messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
     allowCookies="false"> 
     <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <reliableSession ordered="true" inactivityTimeout="00:10:00" 
      enabled="false" /> 
     <security mode="Message"> 
     <transport clientCredentialType="Windows" proxyCredentialType="None" 
     realm="" /> 
     <message clientCredentialType="Windows" negotiateServiceCredential="true" 
     algorithmSuite="Default" establishSecurityContext="true" /> 
     </security> 
    </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://57.23.85.28:8001/MyWCFService/MyWCFService.svc" 
     binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyWCFService" 
     contract="IMyWCFService" name="WSHttpBinding_IMyWCFService"> 
    <identity> 
     <dns value="localhost" /> 
    </identity> 
     </endpoint> 
    </client> 
    </system.serviceModel> 

的Web.Config:

<configuration> 
    <connectionStrings> 
    <add name="DSMyWCF" connectionString="Data Source=XXX;User id=XXX;Password=XXX;"/> 
    </connectionStrings> 
    <system.web> 
    <compilation debug="true" /> 
    </system.web> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <services> 
     <service behaviorConfiguration="MyWCFService.MyWCFServiceBehavior" 
     name="MyWCFService.MyWCFService"> 
     <endpoint address="" binding="wsHttpBinding" contract="MyWCFService.IMyWCFService"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8731/Design_Time_Addresses/MyWCFService/MyWCFService/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="MyWCFService.MyWCFServiceBehavior"> 
      <!-- To avoid disclosing metadata information, 
      set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="True"/> 
      <!-- To receive exception details in faults for debugging purposes, 
      set the value below to true. Set to false before deployment 
      to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="False" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration>  

回答

1

可能與wcf服務的安全配置有關,具體而言,Windows憑據類型需要有效的域用戶名和密碼信息。

嘗試在客戶端提供以下屬性;

proxy.ClientCredentials.Windows.ClientCredential.UserName = "UserName "; 
proxy.ClientCredentials.Windows.ClientCredential.Password = "Password "; 
proxy.ClientCredentials.Windows.ClientCredential.Domain = "Domain ";