Esempio n. 1
0
        public TokenModel Create()
        {
            TokenModel tokenModel = new TokenModel();

            AIRService.WebService.WSSessionCreateRQ.MessageHeader messageHeader = new AIRService.WebService.WSSessionCreateRQ.MessageHeader
            {
                MessageData = new AIRService.WebService.WSSessionCreateRQ.MessageData
                {
                    Timestamp = DateTime.Now.ToString("s").Replace("-", "").Replace(":", "") + "Z"
                },
                ConversationId = "fOV1LWT3EJIUnGC0Yh1",
                Service        = new AIRService.WebService.WSSessionCreateRQ.Service(),
                Action         = "SessionCreateRQ",
                From           = new AIRService.WebService.WSSessionCreateRQ.From
                {
                    PartyId = new AIRService.WebService.WSSessionCreateRQ.PartyId[1]
                }
            };
            var partyID = new AIRService.WebService.WSSessionCreateRQ.PartyId
            {
                Value = "WebServiceClient"
            };

            messageHeader.From.PartyId[0] = partyID;
            messageHeader.To = new AIRService.WebService.WSSessionCreateRQ.To
            {
                PartyId = new AIRService.WebService.WSSessionCreateRQ.PartyId[1]
            };
            partyID = new AIRService.WebService.WSSessionCreateRQ.PartyId
            {
                Value = "WebServiceSupplier"
            };
            messageHeader.To.PartyId[0] = partyID;
            AIRService.WebService.WSSessionCreateRQ.Security security = new AIRService.WebService.WSSessionCreateRQ.Security
            {
                UsernameToken = new AIRService.WebService.WSSessionCreateRQ.SecurityUsernameToken
                {
                    Organization = wSAuthencation.ORGANIZATION,
                    Username     = wSAuthencation.USERNAME,
                    Password     = wSAuthencation.PASSWORD,
                    Domain       = wSAuthencation.DOMAIN
                }
            };
            AIRService.WebService.WSSessionCreateRQ.SessionCreateRQ sessionCreateRQ = new AIRService.WebService.WSSessionCreateRQ.SessionCreateRQ
            {
                returnContextID          = true,
                returnContextIDSpecified = true
            };
            AIRService.WebService.WSSessionCreateRQ.SessionCreatePortTypeClient client = new AIRService.WebService.WSSessionCreateRQ.SessionCreatePortTypeClient();
            client.SessionCreateRQ(ref messageHeader, ref security, sessionCreateRQ);
            tokenModel.ConversationID = messageHeader.ConversationId;
            tokenModel.Token          = security.BinarySecurityToken;
            return(tokenModel);
        }
Esempio n. 2
0
 public TokenModel GetSession()
 {
     try
     {
         AIRService.WebService.WSSessionCreateRQ.MessageHeader messageHeader = new AIRService.WebService.WSSessionCreateRQ.MessageHeader
         {
             MessageData = new AIRService.WebService.WSSessionCreateRQ.MessageData()
         };
         messageHeader.MessageData.Timestamp = DateTime.Now.ToString("s").Replace("-", "").Replace(":", "") + "Z";
         messageHeader.ConversationId        = "fOV1LWT3EJIUnGC0Yh1";// Guid.NewGuid().ToString(); // "fOV1LWT3EJIUnGC0Yh1";
         messageHeader.Service = new AIRService.WebService.WSSessionCreateRQ.Service();
         messageHeader.Action  = "SessionCreateRQ";
         messageHeader.From    = new AIRService.WebService.WSSessionCreateRQ.From
         {
             PartyId = new AIRService.WebService.WSSessionCreateRQ.PartyId[1]
         };
         var partyID = new AIRService.WebService.WSSessionCreateRQ.PartyId
         {
             Value = "WebServiceClient"
         };
         messageHeader.From.PartyId[0] = partyID;
         messageHeader.To = new AIRService.WebService.WSSessionCreateRQ.To
         {
             PartyId = new AIRService.WebService.WSSessionCreateRQ.PartyId[1]
         };
         partyID = new AIRService.WebService.WSSessionCreateRQ.PartyId
         {
             Value = "WebServiceSupplier"
         };
         messageHeader.To.PartyId[0] = partyID;
         AIRService.WebService.WSSessionCreateRQ.Security security = new AIRService.WebService.WSSessionCreateRQ.Security
         {
             UsernameToken = new AIRService.WebService.WSSessionCreateRQ.SecurityUsernameToken
             {
                 Organization = wSAuthencation.ORGANIZATION,
                 Username     = wSAuthencation.USERNAME,
                 Password     = wSAuthencation.PASSWORD,
                 Domain       = wSAuthencation.DOMAIN
             }
         };
         AIRService.WebService.WSSessionCreateRQ.SessionCreateRQ sessionCreateRQ = new AIRService.WebService.WSSessionCreateRQ.SessionCreateRQ
         {
             returnContextID          = true,
             returnContextIDSpecified = true
         };
         AIRService.WebService.WSSessionCreateRQ.SessionCreatePortTypeClient client = new AIRService.WebService.WSSessionCreateRQ.SessionCreatePortTypeClient();
         var data = client.SessionCreateRQ(ref messageHeader, ref security, sessionCreateRQ);
         if (data == null)
         {
             return(null);
         }
         // set data for model ->> return
         var result = new TokenModel
         {
             ConversationID = messageHeader.ConversationId,
             Token          = security.BinarySecurityToken
         };
         return(result);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }