Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using ConsoleApplication1.SessionReference1;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- [STAThread]
- static void Main(string[] args)
- {
- try
- {
- // Set user information, including security credentials and the IPCC.
- string username = "my-username";
- string password = "my-password";
- string ipcc = "not-understand";
- string domain = "EXT";
- string temp = Environment.GetEnvironmentVariable("tmp"); // Get temp directory
- string PropsFileName = temp + "/session.properties"; // Define dir and file name
- DateTime dt = DateTime.UtcNow;
- string tstamp = dt.ToString("s") + "Z";
- //Create the message header and provide the conversation ID.
- MessageHeader msgHeader = new MessageHeader();
- msgHeader.ConversationId = "TestSession"; // Set the ConversationId
- From from = new From();
- PartyId fromPartyId = new PartyId();
- PartyId[] fromPartyIdArr = new PartyId[1];
- fromPartyId.Value = "WebServiceClient";
- fromPartyIdArr[0] = fromPartyId;
- from.PartyId = fromPartyIdArr;
- msgHeader.From = from;
- To to = new To();
- PartyId toPartyId = new PartyId();
- PartyId[] toPartyIdArr = new PartyId[1];
- toPartyId.Value = "WebServiceSupplier";
- 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";
- Service service = new Service();
- service.Value = "SessionCreate";
- msgHeader.Service = service;
- MessageData msgData = new MessageData();
- msgData.MessageId = "mid:20001209-133003-2333@clientofsabre.com1";
- msgData.Timestamp = tstamp;
- msgHeader.MessageData = msgData;
- 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;
- SessionCreatePortTypeClient s = new SessionCreatePortTypeClient();
- SessionCreateRS resp = s.SessionCreateRQ(ref msgHeader, ref security, req);
- //SessionCreateRQService serviceObj = new SessionCreateRQService();
- //serviceObj.MessageHeaderValue = msgHeader;
- //serviceObj.SecurityValue = security;
- //SessionCreateRS rs = new SessionCreateRS();
- //SessionCreateRS = serviceObj.SessionCreateRQ(req); // Send the request
- if (resp.Errors != null && resp.Errors.Error != null)
- {
- Console.WriteLine("Error : " + resp.Errors.Error.ErrorInfo.Message);
- }
- else
- {
- // msgHeader = serviceObj.MessageHeaderValue;
- // security = serviceObj.SecurityValue;
- Console.WriteLine("**********************************************");
- Console.WriteLine("Response of SessionCreateRQ service");
- Console.WriteLine("BinarySecurityToken returned : " + security.BinarySecurityToken);
- Console.WriteLine("**********************************************");
- string ConvIdLine = "convid=" + msgHeader.ConversationId; // ConversationId to a string
- string TokenLine = "securitytoken=" + security.BinarySecurityToken; // BinarySecurityToken to a string
- string ipccLine = "ipcc=" + ipcc; // IPCC to a string
- // File.Delete(PropsFileName); // Clean up
- // TextWriter tw = new StreamWriter(PropsFileName); // Create & open the file
- // tw.WriteLine(DateTime.Now); // Write the date for reference
- // tw.WriteLine(TokenLine); // Write the BinarySecurityToken
- // tw.WriteLine(ConvIdLine); // Write the ConversationId
- // tw.WriteLine(ipccLine); // Write the IPCC
- // tw.Close();
- //Console.Read();
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("Exception Message : " + e.Message);
- Console.WriteLine("Exception Stack Trace : " + e.StackTrace);
- Console.Read();
- }
- }
- }
- }
- string ipcc = "not-understand";
- string domain = "EXT";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement