2011-09-21 31 views
6

Plataforma: VS 2008, .NET 3.5, C#, Oracle 11gautenticación falló al llamar a un servicio WCF desde ASP.NET

he creado un servicio WCF que toma algunos elementos de datos y luego los inserta en una tabla de base de datos y devuelve un número entero. También creé una pequeña aplicación web ASP.NET para probar ese servicio. La aplicación web de prueba solo tiene una página con los campos y un botón, al hacer clic en ese botón en realidad llama al servicio web para insertar los datos y devolver un valor entero.

Los pasos que di:

  • construir el servicio WCF
  • publicar el servicio WCF
  • Generar la clase de proxy (Cs) y utilizando app.config svcutil
  • construir el asp prueba .net y agrega la clase de proxy y las configuraciones de configuración tal como se generaron en el paso anterior.
  • arruinar la aplicación de prueba

Funciona bien cuando puedo implementar tanto la WCF y la aplicación web de prueba en mi ordenador - Windows XP, IIS 5.1. Pero, cada vez que trato de implementarlos en un servidor remoto, no funciona. Cuando estoy tratando de consumir el servicio (desplegado en el servidor remoto - Windows 2003 Server, IIS 6) Estoy consiguiendo el error siguiente:

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.

continuación se enumeran los contenidos archivos .config:

WCF sección del Web.Config de llamar aplicación web ASP.NET (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 de la 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>  

Respuesta

1

Podría estar relacionado con la configuración de seguridad del servicio wcf, para ser específico, el tipo de credencial de Windows requiere información válida de nombre de usuario y contraseña de dominio.

Intente proporcionar los siguientes atributos en el lado del cliente;

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