コード例 #1
0
ファイル: API.cs プロジェクト: agrubin/SiteMinder
        static public async Task <ReadRQResponse> OTA_ReadRQ(string pmsID, string usernameAuthenticate, string passwordAuthenticate, string hotelCode, ResStatus resStatus)
        {
            ReadRQResponse response = null;

            try
            {
                PmsXchangeServiceClient service = new AsyncServiceConnection().service;

                OTA_ReadRQ body = new OTA_ReadRQ()
                {
                    Version = 1.0M, EchoToken = Guid.NewGuid().ToString() /* Echo token must be unique.            */, TimeStamp = DateTime.Now, TimeStampSpecified = true, POS = CreatePOS(pmsID)
                };

                OTA_ReadRQReadRequests readRequests = new OTA_ReadRQReadRequests();
                OTA_ReadRQReadRequestsHotelReadRequest hotelReadRequest = new OTA_ReadRQReadRequestsHotelReadRequest()
                {
                    HotelCode = hotelCode
                };
                readRequests.Items = new object[] { hotelReadRequest };

                OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria selectionCriteria = new OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria()
                {
                    SelectionType = OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteriaSelectionType.Undelivered, SelectionTypeSpecified = true                                                                                                                                         /* Must be set to true, or ReadRQ returns an error.*/
                };

                if (resStatus != ResStatus.All)
                {
                    selectionCriteria.ResStatus = resStatus.ToString();
                }

                hotelReadRequest.SelectionCriteria = selectionCriteria;
                body.ReadRequests = readRequests;

                //
                // Send a retrieve reservations request.
                //

                response = await service.ReadRQAsync(CreateSecurityHeader(usernameAuthenticate, passwordAuthenticate), body).ConfigureAwait(false);
            }
            catch (NullReferenceException)
            {
                Exception exSetup = new Exception("OTA_NotifReportRQ arguments were not set up properly causing a null reference exception.");
                response = new ReadRQResponse();
                response.OTA_ResRetrieveRS       = new OTA_ResRetrieveRS();
                response.OTA_ResRetrieveRS.Items = new object[] { ProcessingException(exSetup) };
            }
            catch (Exception ex)
            {
                response = new ReadRQResponse();
                response.OTA_ResRetrieveRS       = new OTA_ResRetrieveRS();
                response.OTA_ResRetrieveRS.Items = new object[] { ProcessingException(ex) };
            }

            return(response);
        }
コード例 #2
0
ファイル: Connector.cs プロジェクト: hackteur/pms
    static int ConnectSample()
    {
        PmsXchangeService service = new PmsXchangeService();

        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
        //The security header is untyped due to the lax processing instruction
        System.Xml.XmlElement token    = doc.CreateElement("UsernameToken");
        System.Xml.XmlElement password = doc.CreateElement("Password");
        System.Xml.XmlElement username = doc.CreateElement("Username");

        System.Xml.XmlText usernameText = doc.CreateTextNode("SPIOrangeTest");
        System.Xml.XmlText passwordText = doc.CreateTextNode("YOURPASSWORD");
        username.AppendChild(usernameText);
        password.AppendChild(passwordText);
        token.AppendChild(username);
        token.AppendChild(password);

        System.Xml.XmlElement[] elements = new System.Xml.XmlElement[] { token };

        SecurityHeaderType type = new SecurityHeaderType();

        service.Security     = type;
        service.Security.Any = elements;

        OTA_ReadRQ otaReadRQ = new OTA_ReadRQ();

        otaReadRQ.Version = 1.0M;
        OTA_ReadRQReadRequests rr = new OTA_ReadRQReadRequests();
        OTA_ReadRQReadRequestsHotelReadRequest hotelR = new OTA_ReadRQReadRequestsHotelReadRequest();

        hotelR.HotelCode = "123";

        object[] ob = new object[] { hotelR };
        rr.Items = ob;

        OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria crit = new OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria();
        OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteriaSelectionType selType = OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteriaSelectionType.Undelivered;

        crit.SelectionType          = selType;
        crit.SelectionTypeSpecified = true;

        hotelR.SelectionCriteria = crit;
        otaReadRQ.ReadRequests   = rr;
        // Retrieve the response
        Console.WriteLine("About to make request :::");
        OTA_ResRetrieveRS resRetrieveRS = service.ReadRQ(otaReadRQ);

        Console.WriteLine("Received response :::");

        //Do further work ....
        // ....
        return(0);
    }
コード例 #3
0
ファイル: API.cs プロジェクト: hackteur/pms
        static public OTA_ResRetrieveRS OTA_ReadRQ(string pmsID, string usernameAuthenticate, string passwordAuthenticate, string hotelCode, ResStatus resStatus)
        {
            PmsXchangeServiceClient service = ServiceConnection.Instance.service;

            pmsXchangeService.OTA_ReadRQ readRequestBody = new OTA_ReadRQ();
            readRequestBody.Version            = 1.0M;
            readRequestBody.EchoToken          = Guid.NewGuid().ToString(); // Echo token must be unique.
            readRequestBody.TimeStamp          = DateTime.Now;
            readRequestBody.TimeStampSpecified = true;
            readRequestBody.POS = CreatePOS(pmsID);

            pmsXchangeService.OTA_ReadRQReadRequests readRequests = new pmsXchangeService.OTA_ReadRQReadRequests();
            pmsXchangeService.OTA_ReadRQReadRequestsHotelReadRequest hotelReadRequest = new pmsXchangeService.OTA_ReadRQReadRequestsHotelReadRequest();
            hotelReadRequest.HotelCode = hotelCode;
            readRequests.Items         = new object[] { hotelReadRequest };

            OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria selectionCriteria = new pmsXchangeService.OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria();

            selectionCriteria.SelectionType          = pmsXchangeService.OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteriaSelectionType.Undelivered;
            selectionCriteria.SelectionTypeSpecified = true;  // Must be set to true, or ReadRQ returns an error.

            if (resStatus != ResStatus.All)
            {
                selectionCriteria.ResStatus = Enum.GetName(typeof(ResStatus), resStatus);
            }

            hotelReadRequest.SelectionCriteria = selectionCriteria;


            readRequestBody.ReadRequests = readRequests;

            //
            // Send a retrieve reservations request.
            //

            return(service.ReadRQ(CreateSecurityHeader(usernameAuthenticate, passwordAuthenticate), readRequestBody));
        }
コード例 #4
0
        static void Main(string[] args)
        {
            var client = new OTA2009A_ReadReservationsSoapClient(OTA2009A_ReadReservationsSoapClient.EndpointConfiguration.OTA2009A_ReadReservationsSoap);

            client.Open();

            var readRequest = new OTA_ReadRQ
            {
                Version        = 1,
                SchemaLocation = "http://www.opentravel.org/OTA/2003/05 OTA_ReadRQ.xsd",
                EchoToken      = "34267",
                TimeStamp      = DateTime.Now,
                Target         = MessageAcknowledgementTypeTarget.Test,
                POS            = new System.Collections.Generic.List <SourceType>
                {
                    new SourceType
                    {
                        AgentDutyCode = "FERATEL"
                    }
                },
                ReadRequests = new OTA_ReadRQReadRequests
                {
                    Items = new System.Collections.Generic.List <object>
                    {
                        new OTA_ReadRQReadRequestsHotelReadRequest
                        {
                            HotelCode         = "SIMSIM",
                            SelectionCriteria = new System.Collections.Generic.List <OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria>
                            {
                                new OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria
                                {
                                    DateType = OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteriaDateType.LastUpdateDate,
                                    Start    = "2017-04-01",
                                    End      = "2017-04-01",
                                }
                            }
                        }
                    }
                }
            };

            var serializer = new XmlSerializer(typeof(OTA_ReadRQ));
            var encoding   = Encoding.ASCII;
            XmlWriterSettings xmlWriterSettings = new XmlWriterSettings
            {
                Indent             = false,
                OmitXmlDeclaration = true,
                Encoding           = encoding
            };

            using (var stream = new MemoryStream())
            {
                using (var xmlWriter = XmlWriter.Create(stream, xmlWriterSettings))
                {
                    serializer.Serialize(xmlWriter, readRequest);
                }

                var response = client.GetResponseAsync(encoding.GetString(stream.ToArray())).Result;
                Console.WriteLine(response.Body.GetResponseResult);
                Console.ReadKey();
            }

            client.Close();
        }