/// <summary>
        /// Obtiene la cabecera para abrir mensaje enviado por
        /// los servicios de sabre
        /// </summary>
        /// <returns>Cabecera para que abre conexión</returns>
        private serviceOpen.MessageHeader GetOpenMessageHeader()
        {
            DateTime dt     = DateTime.UtcNow;
            string   tstamp = dt.ToString("s") + "Z";

            //Create the message header and provide the conversation ID.
            serviceOpen.MessageHeader msgHeader = new serviceOpen.MessageHeader();
            msgHeader.ConversationId = this.ConversationId;             // Set the ConversationId

            serviceOpen.From      from           = new serviceOpen.From();
            serviceOpen.PartyId   fromPartyId    = new serviceOpen.PartyId();
            serviceOpen.PartyId[] fromPartyIdArr = new serviceOpen.PartyId[1];
            fromPartyId.Value = "99999";
            fromPartyIdArr[0] = fromPartyId;
            from.PartyId      = fromPartyIdArr;
            msgHeader.From    = from;

            serviceOpen.To        to           = new serviceOpen.To();
            serviceOpen.PartyId   toPartyId    = new serviceOpen.PartyId();
            serviceOpen.PartyId[] toPartyIdArr = new serviceOpen.PartyId[1];
            toPartyId.Value = "123123";
            toPartyIdArr[0] = toPartyId;
            to.PartyId      = toPartyIdArr;
            msgHeader.To    = to;

            //Add the value for eb:CPAId, which is the IPCC.
            //Add the value for the action code of this Web service, SessionCreateRQ.

            msgHeader.CPAId  = ipcc;
            msgHeader.Action = "SessionCreateRQ";
            serviceOpen.Service service = new serviceOpen.Service();
            service.Value     = "SessionCreate";
            msgHeader.Service = service;

            serviceOpen.MessageData msgData = new serviceOpen.MessageData();
            msgData.MessageId     = "mid:[email protected]";
            msgData.Timestamp     = tstamp;
            msgHeader.MessageData = msgData;

            return(msgHeader);
        }
        public void OpenConnection()
        {
            if (this.IsConnected)
            {
                return;
            }

            try
            {
                Parameter parameterFirm     = ParameterBL.GetParameterValue("FirmWS");
                Parameter parameterPassword = ParameterBL.GetParameterValue("PasswordWS");
                Parameter parameterPCC      = ParameterBL.GetParameterValue("PCCWS");
                string    username          = parameterFirm.Values;
                string    password          = parameterPassword.Values;
                string    domain            = "DEFAULT";
                this.IPcc           = parameterPCC.Values;
                this.ConversationId = "TestSession";

                DateTime dt     = DateTime.UtcNow;
                string   tstamp = dt.ToString("s") + "Z";

                serviceOpen.MessageHeader msgHeader = GetOpenMessageHeader();

                serviceOpen.Security security = new serviceOpen.Security();
                serviceOpen.SecurityUsernameToken securityUserToken = new serviceOpen.SecurityUsernameToken();
                securityUserToken.Username     = username;
                securityUserToken.Password     = password;
                securityUserToken.Organization = this.IPcc;
                securityUserToken.Domain       = domain;
                security.UsernameToken         = securityUserToken;


                serviceOpen.SessionCreateRQ          req    = new serviceOpen.SessionCreateRQ();
                serviceOpen.SessionCreateRQPOS       pos    = new serviceOpen.SessionCreateRQPOS();
                serviceOpen.SessionCreateRQPOSSource source = new serviceOpen.SessionCreateRQPOSSource();
                source.PseudoCityCode = this.IPcc;
                pos.Source            = source;
                req.POS = pos;

                serviceOpen.SessionCreateRQService serviceObj = new serviceOpen.SessionCreateRQService();
                serviceObj.MessageHeaderValue = msgHeader;
                serviceObj.SecurityValue      = security;


                serviceOpen.SessionCreateRS resp = serviceObj.SessionCreateRQ(req);     // Send the request

                if (resp.Errors != null && resp.Errors.Error != null)
                {
                    string x = "Error : " + resp.Errors.Error.ErrorInfo.Message;
                }
                else
                {
                    msgHeader = serviceObj.MessageHeaderValue;
                    security  = serviceObj.SecurityValue;

                    this.ConversationId = msgHeader.ConversationId;     // ConversationId to a string
                    this.SecurityToken  = security.BinarySecurityToken; // BinarySecurityToken to a string
                    this.DateReference  = DateTime.Now;
                    this.isConnected    = true;
                }
            }
            catch
            {
                this.isConnected = false;
            }
        }