Услуга WCF ошибка conexion.-удостоверений

Я стараюсь соединять услугу WCF безопасно посредством удостоверений, в атмосфере разработки функционирует правильно, в атмосфере, симулируемой с 2 командами, один как услуга и другой как клиент, или в той же команде (услуга и клиент) связь осуществляется правильно, эти команды - в windows 10. Напечатав это на сервере производства, Windows 2012 r2 с iis 8.5, представь ошибку в клиенте:

The caller was not authenticated by the service. The request for security token could not be satisfied because authentication failed. The communication object, System. ServiceModel. Channels. ServiceChannel, cannot be used for communication because it is in the Faulted state.

Я сделал простую консоль это данные Для удостоверений используйте инструкции в этом post

cliente.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cliente
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("-------------------------------------");
try
            {
                using (ServerSinSeguridad.ServicioSinSeguridadClient sinSeguridad = new ServerSinSeguridad.ServicioSinSeguridadClient())
                {
                    Console.WriteLine(sinSeguridad.MostrarDatos("Sin Seguridad"));

                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                if (ex.InnerException != null)
                    Console.WriteLine(ex.InnerException.Message);
            }
            Console.WriteLine("-------------------------------------");
            try
            {
                using (ServerConSeguridad.ServicioConSeguridadClient sinSeguridad = new ServerConSeguridad.ServicioConSeguridadClient())
                {
                    Console.WriteLine(sinSeguridad.MostrarDatos("Con Seguridad"));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                if (ex.InnerException != null)
                    Console.WriteLine(ex.InnerException.Message);
            }
            Console.WriteLine("-------------------------------------");
            try
            {
                using (WSIIsSeguridad.Service1Client sinSeguridad = new WSIIsSeguridad.Service1Client())
                {
                    var c = sinSeguridad.ChannelFactory.CreateChannel();
                    try
                    {
                        Console.WriteLine(c.GetData(123));
                    }
                    catch (Exception we)
                    {
                        Console.WriteLine(we.Message);
                        if (we.InnerException != null)
                            Console.WriteLine(we.InnerException.Message);
                    }

                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                if (ex.InnerException != null)
                    Console.WriteLine(ex.InnerException.Message);
            }
            Console.Read();
        }
    }
}

cliente.config



  
    
  
  
    
      
        
      
      
        
          
            
          
        
        
          
            
          
        
      
    
    
      
        
          
            
          
        
        
          
            
          
        
      
    
    
      
      
        
          
        
      
      
        
          
        
      
    
  

услуга приютивший автомобиль

program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;

namespace ServicioWcf
{
    public class ServicioConSeguridad : IServicioConSeguridad
    {
        public string MostrarDatos(string dato)
        {
            Console.WriteLine(dato);
            return $"Recibido {DateTime.Now}";
        }
    }

    public class ServicioSinSeguridad : IServicioSinSeguridad
    {
        public string MostrarDatos(string dato)
        {
            Console.WriteLine(dato);
            return $"Recibido {DateTime.Now}";
        }
    }

    [ServiceContract]
    public interface IServicioConSeguridad
    {
        [OperationContract]
        string MostrarDatos(string dato);
    }

    [ServiceContract]
    public interface IServicioSinSeguridad
    {
        [OperationContract]
        string MostrarDatos(string dato);
    }

    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                using (ServiceHost sinSeguridad = new ServiceHost(typeof(ServicioSinSeguridad)))
                {
                    using (ServiceHost conSeguridad = new ServiceHost(typeof(ServicioConSeguridad)))
                    {

                        sinSeguridad.Faulted += serviceHost_Faulted;
                        sinSeguridad.UnknownMessageReceived += serviceHost_UnknownMessageReceived;
                        sinSeguridad.Open();


                        conSeguridad.Faulted += serviceHost_Faulted;
                        conSeguridad.UnknownMessageReceived += serviceHost_UnknownMessageReceived;
                        conSeguridad.Open();

                        Console.WriteLine("Listo, Escuchando");
                        Console.Read();
                    }
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                if (ex.InnerException != null)
                    Console.WriteLine(ex.InnerException.Message);
            }
            Console.Read();
        }
        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            if (e.ExceptionObject is Exception)
                Console.WriteLine(((Exception)e.ExceptionObject).Message);
            else
                Console.WriteLine(e.ExceptionObject.ToString());
        }
        static void Build(ref ServiceHost serviceHost, Type service)
        {

            if (serviceHost != null)
            {
                serviceHost.Close();
            }
            // Create a ServiceHost for the CalculatorService type and 
            // provide the base address.
            serviceHost = new ServiceHost(service);

            // Open the ServiceHostBase to create listeners and start 
            // listening for messages.
            serviceHost.Open();
            serviceHost.Faulted += serviceHost_Faulted;
            serviceHost.UnknownMessageReceived += serviceHost_UnknownMessageReceived;

        }
        static void serviceHost_Faulted(object sender, EventArgs e)
        {

        }
        static void serviceHost_UnknownMessageReceived(object sender, UnknownMessageReceivedEventArgs e)
        {
            Console.WriteLine(e.Message.ToString());
        }

    }
}

servicio.config



  
    
  
  
    
      
        
          
          
          
        
        
          
          
          
          
            
          
        
      
    
    
      
        
        
          
            
          
        
      
      
        
        
          
            
          
        
      
    
    
      
        
          
            
          
        
      
    
  

услуга, поселенная в IIS

WcfServiceIIS.svc

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace WcfServiceIIS
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract(Namespace = "Esta.Es.Para.Vos")]
    public interface IService1
    {

        [OperationContract]
        string GetData(int value);

        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);

        // TODO: Add your service operations here
    }


    // Use a data contract as illustrated in the sample below to add composite types to service operations.
    [DataContract]
    public class CompositeType
    {
        bool boolValue = true;
        string stringValue = "Hello ";

        [DataMember]
        public bool BoolValue
        {
            get { return boolValue; }
            set { boolValue = value; }
        }

        [DataMember]
        public string StringValue
        {
            get { return stringValue; }
            set { stringValue = value; }
        }
    }

    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
    public class Service1 : IService1
    {
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }

        public CompositeType GetDataUsingDataContract(CompositeType composite)
        {
            if (composite == null)
            {
                throw new ArgumentNullException("composite");
            }
            if (composite.BoolValue)
            {
                composite.StringValue += "Suffix";
            }
            return composite;
        }
    }
}

web.config




  
    
  
  
    
    
  
  
    
      
        
          
          
          
          
            
              
            
            
          
        
      
    
    
      
        
          
            
          
        
      
    
    
      
        
          
          
            
          
        
      
    
    
    
  
  
    
    
    
  


8
задан 09.05.2019, 10:09
1 ответ

Пробуй размещая этот тип autentificacion в web.con:

<serviceCredentials> 
  <windowsAuthentication allowAnonymousLogons="true"/> 
</serviceCredentials> 
0
ответ дан 03.12.2019, 19:07
  • 1
    Если присоединяется это, ¿ что он реализует? –  Jorgesys♦ 28.04.2018, 02:12