2011-09-21 4 views
6

Piattaforma: VS 2008, .NET 3.5, C#, Oracle 11gAutenticazione non riuscita durante la chiamata servizio WCF da ASP.NET

ho creato un servizio WCF che prende alcuni elementi di dati e poi li inserisce in una tabella di database e restituisce un intero. Ho anche creato una piccola web app ASP.NET per testare quel servizio. L'app web di prova ha solo una pagina con i campi e un pulsante, facendo clic su quel pulsante si chiama effettivamente il servizio web per inserire i dati e restituire un valore intero.

I passi che ho preso:

  • creare il servizio WCF
  • pubblicare il servizio WCF
  • generare la classe proxy (Cs) e app.config utilizzando svcutil
  • costruire l'asp di prova .net app e aggiungere la classe proxy e le impostazioni di configurazione come generate nel passaggio precedente.
  • Rovina l'applicazione di test

Funziona bene quando schiero sia la WCF e la web app di test sul mio computer - Windows XP, IIS 5.1. Ma, ogni volta che sto provando a distribuirli su un server remoto, non funziona. Quando sto cercando di consumare il servizio (distribuito su server remoto - Windows 2003 server, IIS 6) Sto ottenendo il seguente errore:

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.

indicate di seguito il contenuto dei file config:

sezione WCF della Web.Config di chiamare ASP.NET web app (Consumer):

<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 della WCF:

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

risposta

1

Potrebbe essere correlato alla configurazione di sicurezza del servizio wcf, per essere specifici, il tipo di credenziali di Windows richiede le informazioni sul nome utente e sulla password del dominio valido.

Provare a fornire i seguenti attributi sul client;

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