Пример #1
0
        public static SessionCreateRQService Create()
        {
            SessionCreateRQService serviceObj = new SessionCreateRQService();
            SessionCreateRS        resp       = new SessionCreateRS();

            try
            {
                // Set user information, including security credentials and the IPCC.
                string username = "******";
                string password = "******";
                string ipcc     = "4REG";
                string domain   = "DEFAULT";



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


                SessionCreateRQ          req    = new SessionCreateRQ();
                SessionCreateRQPOS       pos    = new SessionCreateRQPOS();
                SessionCreateRQPOSSource source = new SessionCreateRQPOSSource();
                source.PseudoCityCode = ipcc;
                pos.Source            = source;
                req.POS = pos;


                serviceObj.MessageHeaderValue = Get("SessionCreateRQ", "SessionCreate");
                serviceObj.SecurityValue      = security;


                resp = serviceObj.SessionCreateRQ(req);
            }
            catch (Exception e)
            {
                throw new Exception(e.InnerException.ToString());
            }

            return(serviceObj);
        }
 /// <summary>
 /// Calls this instance.
 /// </summary>
 public void Call()
 {
     try
     {
         var createRequestSession = new SessionCreateRQ
         {
             POS =
                 new SessionCreateRQPOS
             {
                 Source = new SessionCreateRQPOSSource
                 {
                     PseudoCityCode = VolarisResources.PseudoCodeCity
                 }
             }
         };
         var service = new SessionCreateRQService
         {
             MessageHeaderValue = this.GetMessageHeader(),
             SecurityValue      = this.GetSecurityHeader(),
         };
         Serializer.Serialize("SessionCreateRQ", createRequestSession);
         var response = service.SessionCreateRQ(createRequestSession);
         Serializer.Serialize("SessionCreateRS", response);
         if (response.Errors != null)
         {
             Success      = false;
             ErrorMessage = "No se pudo establecer una enlace con volaris, verifique que tenga acceso a internet, en caso de persistir el problema reportarlo a soporte tecnico.";
             return;
         }
         this.SecurityToken  = service.SecurityValue.BinarySecurityToken;
         this.ConversationID = service.MessageHeaderValue.ConversationId;
         Success             = true;
     }
     catch (SoapException soapException)
     {
         var ed = soapException;
         Success      = false;
         ErrorMessage = "No se pudo establecer una enlace con volaris, verifique que tenga acceso a internet, en caso de persistir el problema reportarlo a soporte tecnico.";
     }
 }
Пример #3
0
        /// <summary>
        /// Creates a new session asynchronously.
        /// </summary>
        /// <param name="conversationId">The conversation identifier.</param>
        /// <returns>The SOAP result containing the SessionCreate response.</returns>
        public async Task <SoapResult <SessionCreateRS> > CreateSessionAsync(string conversationId)
        {
            SessionCreateRQ        request = this.soapServiceFactory.CreateSessionCreateRequest();
            SessionCreateRQService service = this.soapServiceFactory.CreateSessionCreateService(conversationId);

            // This is an asynchronous SOAP call.
            // We need to convert event-based asynchrous call to task-based one.
            // The event is triggered when the action is completed.
            // Then it sets the result and ends the task.
            var source = new TaskCompletionSource <SoapResult <SessionCreateRS> >();

            service.SessionCreateRQCompleted += (s, e) =>
            {
                if (SoapHelper.HandleErrors(e, source))
                {
                    source.TrySetResult(SoapResult <SessionCreateRS> .Success(e.Result, service.SecurityValue));
                }
            };
            service.SessionCreateRQAsync(request);

            // Return the asynchronous task.
            return(await source.Task);
        }