locked
Caller was not authenticated by the service RRS feed

  • Question

  •  

    Hi all:

    I am trying  to create a client-host application based on WCF. When running both on the same station everything is working fine, but when running each on a seperate computer am getting the following error:

     

    System.ServiceModel.Security.SecurityNegotiationException was unhandled
      Message="The caller was not authenticated by the service."

     

    here is the code of the host:

     

    Code Block

        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Oppening a new endpoint");           
                ServiceHost host = new ServiceHost(typeof(MyService));

                WSDualHttpBinding binding = new WSDualHttpBinding();
                binding.Security.Mode = WSDualHttpSecurityMode.Message;
                binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;

                binding.Security.Message.NegotiateServiceCredential = true;           

                Uri address = new Uri("http://localhost:8080/WorkflowServices");
                EndpointAddress ea = new EndpointAddress(address);

                ContractDescription contract = ContractDescription.GetContract(typeof(IMyService));
                ServiceEndpoint se = new ServiceEndpoint(contract, binding, ea);
                host.Description.Endpoints.Add(se);

                host.Open();

                Console.WriteLine("WCF Service is running");
                Console.WriteLine("Press to stop the service");
                Console.ReadLine();
                host.Close();
            }
        }

     

     

    here is the code of the client:

    Code Block

        public class Program
        {
                   
            static void Main(string[] args)
            {                       
                Console.WriteLine("Starting the main function");

                WSDualHttpBinding clientBinding = new WSDualHttpBinding();           
                clientBinding.Security.Mode = WSDualHttpSecurityMode.Message;
                clientBinding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;

                clientBinding.Security.Message.NegotiateServiceCredential = true;

                Uri address = new Uri("http://server:8080/WorkflowServices");
                EndpointAddress ea = new EndpointAddress(address);
                InstanceContext context = new InstanceContext(new CallBackHandler());

                DuplexChannelFactory<IMyService> factory = new DuplexChannelFactory<IMyService>(context, clientBinding, ea);           

                IMyService myservice = factory.CreateChannel();

                Console.WriteLine("Oppening Services");
                ((IClientChannel)myservice).Open();
                Console.WriteLine("press <Enter> to close Service");
                Console.ReadLine();
                ((IClientChannel)myservice).Close();
                Console.WriteLine("Service Closed");
            }
        }

     

     

     

    Note: instead of using app.config i am using the code directly to set the configuration of the endpoints and binding.

    when using WSHttpBinding instead of WSDualHttpBinding the application runs properly, but i am using WSDualHttpBinding beacuse it is needed for call back functions.

     

    i have run over a lot of blogs on the internet, but non helped, incase you have an idea of how to solve it please help.

     

    Wednesday, November 21, 2007 6:22 PM

Answers

All replies