Using Credentials

Sep 22, 2010 at 2:25 PM

Regards, in  Walkthrough example using the credentials, we are working with WSCF for the development our web services, but when using the Credentials with RestaurantHeaderData, We want to use SOAP headers to transport the authentication credentials however in the implementation in visual studio 2005 the parameters have value nulls, attach my file, please help with explain how do use credentials for authentication.

 

Please Help me

Thanks’.

 Coding:

 public partial class ReformaDistributivoPort : System.Web.Services.WebService, IReformaDistributivoPort

    {

       

        private Credentials userCredentials;

       

        public ReformaDistributivoPort()

        {

        }

       

        public ReformaDistributivoPort(Credentials userCredentials)

        {

            this.userCredentials = userCredentials;

        }

       

        [System.Xml.Serialization.XmlElementAttribute(ElementName="userCredentials")]

        public Credentials UserCredentials

        {

            get

            {

                return this.userCredentials;

            }

            set

            {

                if ((value == null))

                {

                    throw new System.ArgumentNullException("UserCredentials");

                }

                if ((this.userCredentials != value))

                {

                    this.userCredentials = value;

                }

            }

        }

       

        /// <remarks/>

        [System.Web.Services.Protocols.SoapHeaderAttribute("UserCredentials")]

        [System.Web.Services.WebMethodAttribute()]

        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("reformaDistributivo:reformaIn", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare, Binding="reformaDistributivo")]

        [return: System.Xml.Serialization.XmlElementAttribute("reformaResponse", Namespace="http://tempuri.org/reformasMensaje.xsd")]

        public virtual ReformaResponse Reforma([System.Xml.Serialization.XmlElementAttribute(Namespace="http://tempuri.org/reformasMensaje.xsd", ElementName="reformaRequest")] ReformaRequest reformaRequest)

        {

            ReformaResponse respuesta = new ReformaResponse();

            RefNegocio negocio = new RefNegocio();

            Resultado resultadoacceso = new Resultado();

            ReformaDistributivoPort variable = new ReformaDistributivoPort();

           

           

            Credentials acceso = new Credentials();

            acceso.a = variable.UserCredentials;

            acceso.Clave = UserCredentials.Clave;

            resultadoacceso = negocio.controlar_acceso(acceso.Usuario, acceso.Clave);

            if (resultadoacceso.Estado =="1")

            {

                respuesta = negocio.Reforma(reformaRequest);

            }

            else {

                respuesta.Estado = "RZ";

                respuesta.Mensage = resultadoacceso.Mensage;

                respuesta.IdReforma = reformaRequest.Cabecera.IdReforma;

            } 

            return respuesta;

        }

    }

}