Ejemplo n.º 1
0
        public AvailabilityFightListResponse AvailabilityFightList(AvailabilityFightListRequest request)
        {
            List<AvailabilityFight> flights = new List<AvailabilityFight>();

            AvailabilityFightListResponse response = new AvailabilityFightListResponse();

            //try
            //{

            //    var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
            //    basicHttpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
            //    basicHttpBinding.SendTimeout = new System.TimeSpan(0, 5, 0);

            //    SunExpressCraneOTAServiceExtendedServiceReference.CraneOTAServiceExtendedPortTypeClient client = new SunExpressCraneOTAServiceExtendedServiceReference.CraneOTAServiceExtendedPortTypeClient(basicHttpBinding, new EndpointAddress("https://ota.sunexpress.com/axis2/services/CraneOTAServiceExtended?wsdl"));

            //    client.ClientCredentials.UserName.UserName = "******";
            //    client.ClientCredentials.UserName.Password = "******";

            //    if (client.InnerChannel.State != System.ServiceModel.CommunicationState.Faulted)
            //    {
            //        var res = client.Ping(new SunExpressCraneOTAServiceExtendedServiceReference.OTA_PingRQType() { SequenceNmbr = 1, TimeStamp = "1", EchoData = "this is a ping." });
            //    }
            //    else
            //    {
            //        client = new SunExpressCraneOTAServiceExtendedServiceReference.CraneOTAServiceExtendedPortTypeClient(basicHttpBinding, new EndpointAddress("https://ota.sunexpress.com/axis2/services/CraneOTAServiceExtended?wsdl"));
            //        client.ClientCredentials.UserName.UserName = "******";
            //        client.ClientCredentials.UserName.Password = "******";

            //        var res = client.Ping(new SunExpressCraneOTAServiceExtendedServiceReference.OTA_PingRQType() { SequenceNmbr = 1, TimeStamp = "1", EchoData = "this is a ping." });

            //    }
            //}catch  ()
            //{
            //}

            try
            {
                //SunExpressXMLServiceReference.CraneOTAService cc = new SunExpressXMLServiceReference.CraneOTAService();

                //var res = cc.Ping(new SunExpressXMLServiceReference.OTA_PingRQType() {  });
                //cc.Availability(new SunExpressXMLServiceReference.OTA_AirAvailRQType()
                //    {
                //        PrimaryLangID= "TR",
                //        POS= new SunExpressXMLServiceReference.POSType(),

                //        DirectFlightsOnly = true,
                //        OriginDestinationInformation = new SunExpressXMLServiceReference.OriginDestinationInformationType()
                //        {
                //            DepartureDateTime = "20160808",
                //            DestinationLocation = new SunExpressXMLServiceReference.LocationType() { LocationCode = "AYT" },
                //            OriginLocation = new SunExpressXMLServiceReference.LocationType() { LocationCode = "IST" }
                //        }
                //    });
                //header = new SunExpressSoapHeader(username, password);
                header = new SunExpressSoapHeader();
                header.Username = "******";
                header.Password = "******";

                try
                {

                    //SunExpressServiceReference.CraneOTAServicePortTypeClient xc = new SunExpressServiceReference.CraneOTAServicePortTypeClient("CraneOTAServiceSOAP12port_http2");

                    //var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
                    //basicHttpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;

                    //xc.ClientCredentials.UserName.UserName = "******";
                    //xc.ClientCredentials.UserName.Password = "******";

                    //xc.Ping(new SunExpressServiceReference.OTA_PingRQType() { SequenceNmbr = 1, TimeStamp = "1", EchoData = "this is a ping." });

                }
                catch (System.Exception)
                {

                }

                //SunExpressXMLServiceReference.CraneOTAService cc = new SunExpressXMLServiceReference.CraneOTAService();
                //var resp = cc.Ping(new SunExpressXMLServiceReference.OTA_PingRQType() { SequenceNmbr = 1, TimeStamp = "1", EchoData = "this is a ping." });
                var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
                basicHttpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
                basicHttpBinding.SendTimeout = new System.TimeSpan(0, 5, 0);

                //https://ota.sunexpress.com/axis2/services/CraneOTAServiceExtended?wsdl
                using (SunExpressServiceReference.CraneOTAServicePortTypeClient client = new SunExpressServiceReference.CraneOTAServicePortTypeClient(basicHttpBinding, new EndpointAddress("https://ota.sunexpress.com:80/axis2/services/CraneOTAService?wsdl")))
                {

                    client.ClientCredentials.UserName.UserName = "******";
                    client.ClientCredentials.UserName.Password = "******";

                    ////header = new SunExpressSoapHeader(username, password);
                    //using (new OperationContextScope(client.InnerChannel))
                    //{
                    //    //// Add a HTTP Header to an outgoing request
                    //    //HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty();
                    //    //requestMessage.Headers["MyHttpHeader"] = header.ToString();
                    //    //OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage;

                    //    var res = client.Ping(new SunExpressServiceReference.OTA_PingRQType() { });
                    //}

                    ////header = new SunExpressSoapHeader(username, password);
                    //using (new OperationContextScope(client.InnerChannel))
                    //{
                    //    //// Add a HTTP Header to an outgoing request
                    //    //HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty();
                    //    //requestMessage.Headers["MyHttpHeader"] = header.ToString();
                    //    //OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage;

                    //    var res = client.Ping(new SunExpressServiceReference.OTA_PingRQType() { SequenceNmbr = 1, TimeStamp = "1", EchoData = "this is a ping." });
                    //}

                    using (new OperationContextScope(client.InnerChannel))
                    {

                        //// Add a HTTP Header to an outgoing request
                        HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty();
                        requestMessage.Headers["Header"] = "Content-Type: text/xml; charset=utf-8"; // "Content-Type: application/soap+xml; charset = utf-8";

                        OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage;

                        MessageHeader aMessageHeader = MessageHeader.CreateHeader("wsse:Security", "", header);
                        OperationContext.Current.OutgoingMessageHeaders.Add(aMessageHeader);

                        var res = client.Ping(new SunExpressServiceReference.OTA_PingRQType() { SequenceNmbr = 1, TimeStamp = "1", EchoData = "this is a ping." });

                        //var res = client.Ping(new SunExpressServiceReference.OTA_PingRQType() { SequenceNmbr = 1, TimeStamp = "1", EchoData = "this is a ping." });
                    }

                    client.Close();
                }

                //using (SunExpressServiceReference.CraneOTAServicePortTypeClient client = new SunExpressServiceReference.CraneOTAServicePortTypeClient("CraneOTAServiceSOAP11port_http2"))
                //{

                //    header = new SunExpressSoapHeader(username, password);

                //    var res = client.Availability(new SunExpressServiceReference.OTA_AirAvailRQType()
                //    {
                //        DirectFlightsOnly = true,
                //        OriginDestinationInformation = new SunExpressServiceReference.OriginDestinationInformationType()
                //        {
                //            DepartureDateTime = "20160808",
                //            DestinationLocation = new LocationType() { LocationCode = "AYT" },
                //            OriginLocation = new LocationType() { LocationCode = "ESB" }
                //        }
                //    });
                //    //SunExpressServiceReference.AvailabilityData availabilityResponse = client.availabilityV3(request.username, request.password, request.lang, request.direction.ToString(), request.origin, request.destination, request.date, request.adult, request.child, request.inf, request.ogr, request.tsk, request.yp, request.sc, request.tripType.ToString());

                //    //if (availabilityResponse != null && availabilityResponse.flightData != null)
                //    //{

                //    //    if (availabilityResponse.flightData.Length > 1)
                //    //    {
                //    //        foreach (var flight in availabilityResponse.flightData)
                //    //        {
                //    //            flights.Add(new AvailabilityFight() { Message = flight.message, Voyagecode = flight.voyagecode });
                //    //        }
                //    //    }
                //    //    else
                //    //    {
                //    //        ///log yazıp geçeceğiz...
                //    //    }
                //    //    response.Entities = flights;
                //    //    response.TotalCount = flights.Count;
                //    //}

                //    client.Close();
                //}
            }
            catch (System.Exception)
            {

            }

            return response;
        }
Ejemplo n.º 2
0
        public SunExpress(string Username, string Password)
        {
            Username = "******";
            Password = "******";

            username = Username;
            password = Password;

            //header = new SunExpressSoapHeader(username,password);
            header = new SunExpressSoapHeader();
            header.Username = "******";
            header.Password = "******";
        }