WCF and Windows Authentication

Hello

I am hosting a WCF service within an ASP.net application that uses windows authentication to identify and authenticate its users. Now I am trying to consume these WCF services on my android client which requires that my android application authenticates itself using windows authentication before it could access the service, I am trying the following code, but unfortunately it throws and exception.

        EmployeeServicesWCFClient empServices = new EmployeeServicesWCFClient();
            BasicHttpBinding binding = new BasicHttpBinding();
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;

            EndpointAddress endpoint = new EndpointAddress("http://10.0.2.2/cse/EmpServices/EmployeeServicesWCF.svc");

            empServices = new EmployeeServicesWCFClient(binding, endpoint);
            empServices.ClientCredentials.UserName.UserName = "10.0.2.2\\Mostafa";
            empServices.ClientCredentials.UserName.Password = "password";

    Employee emp = empServices.GetEmployeeInfo();

when the above code is executed, the line below in the WCF generated proxy class throws a null reference exception

            public CSEDataContracts.Employee GetEmployeeInfo()
                {
                    return base.Channel.GetEmployeeInfo();
                }

P.S. I have windows authentication enabled and anonymous authentication disabled for the website configuration in the IIS.

any idea what is the problem?

Posts

  • kocak_bariskocak_baris BEMember

    No explanation no source for this issue.. There is no config file in the project WTF..
    Im searching for 2 days how to solve this problem but in every forum there is question but no response..
    im sick of this..

  • MostafaElAwadyMostafaElAwady EGMember ✭✭

    I have worked around it by send the username and password with each method call, then using impersonation on the server side hosting the service to manually do the authentication locally.

    FYI, xamarin support answer was that their framework doesn't support the WCF Windows authentication combo.

    Good luck

Sign In or Register to comment.