ASMX: Issue to send user credentails from client side to service end RRS feed

  • Question

  • i consult these two web site just to know how to work with soap header

    i also develop my web service this way. see the code

    namespace CustomAuthWithHTTPModule
        /// <summary>
        /// Summary description for SecureWebService
        /// </summary>
        public class Authentication : SoapHeader
            public string User;
            public string Password;
        public class SecureWebService : WebService
            public Authentication authentication;
            [SoapHeader("authentication", Required = true)]
            public string ValidUser()
                if (User.IsInRole("Customer"))
                    return "User is in role customer";
                if (User.Identity.IsAuthenticated)
                    return "User is a valid user";
                return "not authenticated";

    in my console apps i create the proxy of the above web service just by add web reference. the problem is AuthHeaderValue or UserCredentialsValue both property is not being expose at client side by which i can send user credentials. see my client code

    ServiceReference1.SecureWebServiceSoapClient xx = new ServiceReference1.SecureWebServiceSoapClient();
    ServiceReference1.Authentication a = new ServiceReference1.Authentication();
    a.User = "Hello";
    a.Password = "Hello";
    xx.AuthHeaderValue  or xx.UserCredentialsValue // not being expose

    guide me where i made the mistake. i am working with VS2013 IDE. thanks

    Wednesday, December 21, 2016 8:05 AM


  •             ServiceReference1.AuthenticateHeader oAuth = new ServiceReference1.AuthenticateHeader();
                oAuth.UserName = "Test";
                oAuth.Password = "Test";
                ServiceReference1.Test1SoapClient oClient =new ServiceReference1.Test1SoapClient();
                    oClient.Add(oAuth, 2, 3);
                catch(SoapException SoapEx)
                    //string strMsg=SoapEx.
                catch (Exception Ex)

    we need to pass oAuth as parameter to those web service function which has SoapHeader attribute  [SoapHeader("Credentials", Required = true)]

    this issue is solved now. thanks

    • Marked as answer by Sudip_inn Wednesday, December 21, 2016 1:25 PM
    Wednesday, December 21, 2016 1:24 PM