예제 #1
0
        public void WhenCloningGetTotalPriceShouldReturnProperValue()
        {
            var configurationList = new CarConfigurationManager();
            var bmw = new CarModel()
            {
                Name      = "BMW",
                BasePrice = 100000
            };

            var engineUpgrade = new CarPart()
            {
                Name  = "V12",
                Price = 50000
            };
            var breaksUpgrade = new CarPart()
            {
                Name  = "ExtraBreaks",
                Price = 20000
            };

            var configuration = new CarConfiguration("BMWV12", bmw, new List <CarPart>()
            {
                engineUpgrade, breaksUpgrade
            });

            configurationList["BMWV12"] = configuration;

            var clonedConfiguration = configurationList["BMWV12"].Clone() as CarConfiguration;

            clonedConfiguration.GetTotalPrice().Should().Be(configuration.GetTotalPrice());
        }
예제 #2
0
        // Update the SettingName by using inputted SettingValue and return original SettingValue
        public static string updatePosSettingValue(string settingName, string settingValue, string jurisdictionCode, string companyCode, string managementUnitCode)
        {
            string origSettingValue = string.Empty;
            string envName          = CarConfigurationManager.AppSetting("EnvironmentName");
            string urlName          = "CarWorldspanSCSUri";
            ConfigurationDBHelper configurationDBhelper = new ConfigurationDBHelper(CarCommonEnumManager.ServiceName.CarWorldspanSCS, ConfigSettingType.POS);

            // 1.Search PosConfiguration table by EnvironmentName and POS
            origSettingValue = configurationDBhelper.SettingValuePOSGet(settingName, envName, jurisdictionCode, companyCode, managementUnitCode);
            if (!string.IsNullOrEmpty(origSettingValue))
            {
                RequestSender.SendServiceConfigHttpRequest(urlName, settingName, settingValue, jurisdictionCode, companyCode, managementUnitCode);
                return(origSettingValue);
            }
            // 2.Search PosConfiguration table by EnvironmentName and POS as NULL
            origSettingValue = configurationDBhelper.SettingValuePOSGet(settingName, envName);
            if (!string.IsNullOrEmpty(origSettingValue))
            {
                RequestSender.SendServiceConfigHttpRequest(urlName, settingName, settingValue);
                return(origSettingValue);
            }
            // 3.Search PosConfiguration table by EnvironmentName as NULL and POS as NULL
            origSettingValue = configurationDBhelper.SettingValuePOSGet(settingName);
            if (!string.IsNullOrEmpty(origSettingValue))
            {
                RequestSender.SendServiceConfigHttpRequest(urlName, settingName, setEnv: false);
                return(origSettingValue);
            }
            else
            {
                return(origSettingValue);
            }
        }
        public static WebRequest CreateWebRequestHeader(CommunicationInformation commInfo)
        {
            HttpWebRequest request = null;

            request = (HttpWebRequest)WebRequest.Create(commInfo.URI);
            if (commInfo.HttpSendMode == CommunicationInformation.HTTPSendMode.GET)
            {
                if (commInfo.ContentType == MessageFormat.MessageContentType.Json)
                {
                    request.Accept = "application/json";
                }
                //else request.Accept = "application/xml";
            }
            request.Method      = commInfo.HttpSendMode.ToString();
            request.Timeout     = Convert.ToInt32(CarConfigurationManager.AppSetting("HttpRequestTimeOut"));
            request.ContentType = getContentType(commInfo.ContentType, commInfo.MessageProtocol);


            if (commInfo.ContentEncoding != MessageEncodeDecode.MessageContentEncoding.None)
            {
                request.Headers.Add("Accept-Encoding", commInfo.ContentEncoding.ToString());
            }

            //add OriginalGUID in request header
            printRequestHeader(commInfo);
            return(request);
        }
예제 #4
0
        public static string getPoSSettingValue(string settingName, string jurisdictionCode, string companyCode, string managementUnitCode)
        {
            string settingValue = string.Empty;
            string envName      = CarConfigurationManager.AppSetting("EnvironmentName");

            if (envName == null)
            {
                envName = GetEnvFromAPPConfig();
            }
            ConfigurationDBHelper configurationDBhelper = new ConfigurationDBHelper(CarCommonEnumManager.ServiceName.CarWorldspanSCS, ConfigSettingType.POS);

            // 1.Search PosConfiguration table by EnvironmentName and POS
            settingValue = configurationDBhelper.SettingValuePOSGet(settingName, envName, jurisdictionCode, companyCode, managementUnitCode);
            // 2.Search PosConfiguration table by EnvironmentName and POS as NULL
            if (string.IsNullOrEmpty(settingValue))
            {
                settingValue = configurationDBhelper.SettingValuePOSGet(settingName, envName);
            }
            // 3.Search PosConfiguration table by EnvironmentName as NULL and POS as NULL
            if (string.IsNullOrEmpty(settingValue))
            {
                settingValue = configurationDBhelper.SettingValuePOSGet(settingName);
            }
            return(settingValue);
        }
예제 #5
0
        public static String BuildUpdateURL(String settingName, String settingValue)
        {
            //Get the WSCSURL from app settings(E.g: http://chelcarjvafc01:52048/stt03.com-expedia-s3-cars-supplyconnectivity-worldspan.urn:com:expedia:s3:cars:supplyconnectivity:interface:v4" />)
            String uri = CarConfigurationManager.AppSetting("CarBSUri");;

            //Get the environmnet form WSCS URL, E.g: stt03
            String env = ServiceConfigUtil.EnvNameGet();//GetEnvFromAPPConfig();

            uri = "http://" + uri.Substring(7).Split('/')[0] + "/config/set?&environment=" + env;

            uri = uri + "&settingName=" + settingName + "&value=" + settingValue + "&updatedBy=CarBSServiceAutomationTest&flushAll=1";

            ////Combine the URL for service setting config
            //uri = "http://" + uri.Substring(7).Split('/')[0] + "/config/set?&environment=" + env + "&companyCode=" + companyCode + "&managementUnitCode="
            //    + managementUnitCode + "&jurisdictionCode=" + jurisdictionCode + "&settingName=" + settingName + "&value=" + settingValue
            //    + "&updatedBy=CarBSServiceAutomationTest&flushAll=1";

            return(uri);
        }
        public static HttpWebRequest CreateRequestHeader(CommunicationInformation commInfo)
        {
            HttpWebRequest request = null;

            request           = (HttpWebRequest)WebRequest.Create(commInfo.URI);
            request.Pipelined = false;
            request.Method    = commInfo.HttpSendMode.ToString();
            request.KeepAlive = true;
            request.Timeout   = Convert.ToInt32(CarConfigurationManager.AppSetting("MessageRequestTimeout"));

            if (commInfo.ContentEncoding != MessageEncodeDecode.MessageContentEncoding.None)
            {
                request.Headers.Add("Accept-Encoding", commInfo.ContentEncoding.ToString());
            }

            string contentType = "application/";

            if (commInfo.MessageProtocol == MsgProtocol.SOAP)
            {
                contentType += "soap+";
            }

            switch (commInfo.ContentType)
            {
            case MessageFormat.MessageContentType.Xml:
                contentType += "xml";
                break;

            case MessageFormat.MessageContentType.FastInfoSet:
                contentType += "fastinfoset";
                break;

            default:
                throw new ArgumentOutOfRangeException("msgContentType");
            }

            request.ContentType = contentType;

            return(request);
        }
        /// add by v-pxie 2013-11-22: support for the GUID list with one TUID and requestNmae
        public static HttpWebResponse SendReqAndRecvResp(MemoryStream ms, CommunicationInformation commInfo, string requestTypeName = null)
        {
            if (ms == null)
            {
                throw new ArgumentNullException("ms");
            }

            if (commInfo == null)
            {
                throw new ArgumentNullException("commInfo");
            }

            HttpWebRequest httpWebRequest = CreateRequestHeader(commInfo);

            // If need spoofer, get OriginalGUID by TestCaseID; otherwise, generate a new GUID
            string originalGUID = "";

            if (Convert.ToBoolean(CarConfigurationManager.AppSetting("NeedSpoofer")) == true)
            {
                /// add by v-pxie 2013-11-22: support for the GUID list with one TUID and requestNmae
                originalGUID = EmbededFileOperation.getGUIDFromEmbededFile(commInfo.TestCaseID);
            }
            else
            {
                originalGUID = Guid.NewGuid().ToString();
            }

            // E3JMS-L-activityId
            // Note: If need Spoofer, whatever the value in WithE3JRequestHeader, we all need to add OriginalGUID in request header.
            if (Convert.ToBoolean(CarConfigurationManager.AppSetting("NeedSpoofer")) == true || commInfo.WithE3JRequestHeader)
            {
                httpWebRequest.Headers.Add("e3jms-l-activityId-propname", "activityId");
                httpWebRequest.Headers.Add("E3JMS-L-activityId", originalGUID);
            }

            // Send E3J request with httpWebRequest.Headers.
            if (commInfo.WithE3JRequestHeader)
            {
                // E3JMS-L-origServerName
                httpWebRequest.Headers.Add("E3JMS-L-origServerName", Environment.MachineName);

                // E3JMS-L-serviceName
                httpWebRequest.Headers.Add("E3JMS-L-serviceName", System.Diagnostics.Process.GetCurrentProcess().ProcessName);

                // e3jms-l-stand-rep
                httpWebRequest.Headers.Add("e3jms-l-stand-rep", "TQ:e3Interop");

                // E3JMS-L-stand-mes
                String messageId = originalGUID + "-" + Guid.NewGuid();
                httpWebRequest.Headers.Add("E3JMS-L-stand-mes", messageId);
            }

            if (commInfo.HttpSendMode == CommunicationInformation.HTTPSendMode.POST)
            {
                httpWebRequest.Accept = httpWebRequest.ContentType;
            }

            httpWebRequest.ContentLength = ms.GetBuffer().Length;
            if (httpWebRequest.ContentLength > 0)
            {
                httpWebRequest.GetRequestStream().Write(ms.GetBuffer(), 0, ms.GetBuffer().Length);
            }
            return(SendRequestAndReceiveResponse(httpWebRequest));
        }
        public static ResponseT send <RequestT, ResponseT>(RequestT reqObj, CommunicationInformation commInfo, uint tuid = 0, bool replaceFlag = false)
        {
            if (reqObj == null)
            {
                throw new ArgumentNullException("reqObj is null.");
            }

            if (commInfo == null)
            {
                throw new ArgumentNullException("commInfo is null.");
            }

            MemoryStream msReq = null;
            MemoryStream msRsp = null;

            // for Sprunk to show message with
            if (NeedPrintMessageToConsole)
            {
                Console.WriteLine("Run Test case on Server :" + commInfo.URI);
                Console.Error.WriteLine("Now Run Test case on Server :" + commInfo.URI);
                Console.WriteLine("-----------Request:-----------");
                Print.PrintMessageToConsole(reqObj);
            }

            // Serialize Request [obj] to [objXML]
            msReq = XMLSerializer.Serialize(reqObj, typeof(RequestT));

            // Attach Protocol [objXML] to [Hdr + objXML]
            msReq = MessageProtocol.AttachProtocol(msReq, commInfo);

            // Serialize Request [Hdr + objXML] to [FI[Hdr + objXML]]
            msReq = MessageFormat.Serialize(msReq, commInfo.ContentType);

            // Encode Request [FI[Hdr + objXML]] to [GZip[FI[Hdr + objXML]]]
            msReq = MessageEncodeDecode.Encode(msReq, commInfo.ContentEncoding.ToString());

            // Send/Recv Request/Response
            if (NeedPrintMessageToConsole)
            {
                Console.WriteLine(string.Format("-----------Begin to send request to service, transport encoding is {0}: -----------", commInfo.ContentType.ToString()));
            }
            // It's just for spoofer
            if (Convert.ToBoolean(CarConfigurationManager.AppSetting("NeedSpoofer")) == true)
            {
                if (tuid > 0)
                {
                    commInfo.TestCaseID = tuid;
                    if (NeedPrintMessageToConsole)
                    {
                        Console.WriteLine("TUID from parameter:" + tuid + "!");
                    }
                }
                else
                {
                    commInfo.TestCaseID = CarCommonRequestGenerator.getTUIDFromRequest(reqObj);
                    {
                        if (commInfo.TestCaseID == 0)
                        {
                            Console.WriteLine("TUID can't be get from request object!");
                        }
                        else
                        {
                            Console.WriteLine("TUID from request object:" + commInfo.TestCaseID + "!");
                        }
                    }
                }
            }
            else
            {
                if (NeedPrintMessageToConsole)
                {
                    Console.WriteLine("Spoofer is off, no testcaseID get!");
                }
            }
            ResponseT       rspobj          = default(ResponseT);
            string          statusCode      = "";
            HttpWebResponse httpWebResponse = SendReqAndRecvResp(msReq, commInfo, typeof(RequestT).Name);

            if (null != httpWebResponse)
            {
                statusCode = httpWebResponse.StatusCode.ToString();
            }

            MemoryStream msRspReturn = CommunicationUtil.StreamToMemoryStream(httpWebResponse.GetResponseStream());

            if (msRspReturn == null || msRspReturn.Length == 0)
            {
                throw new Exception("Response is empty or Null, please check.");
            }
            else
            {
                // Decode Response [GZip[FI[Hdr + objXML]]] to [FI[Hdr + objXML]]
                msRspReturn = MessageEncodeDecode.Decode(msRspReturn, httpWebResponse.ContentEncoding);

                // DeSerialize Response [FI[Hdr + objXML]] to [Hdr + objXML]
                msRspReturn = MessageFormat.Deserialize(msRspReturn, commInfo.ContentType);

                // Detach Protocol [Hdr + objXML] to [objXML]
                msRspReturn = MessageProtocol.DetachProtocol(msRspReturn, commInfo.MessageProtocol);

                msRsp = msRspReturn;
                // handle aws namespace issue
                if (replaceFlag)
                {
                    string siteName = ServiceConfigUtil.CarProductTokenUriGet();
                    if (siteName.Contains("cars-business-service"))
                    {
                        string responseStr = System.Text.Encoding.GetEncoding(httpWebResponse.CharacterSet).GetString(msRspReturn.ToArray());
                        responseStr = responseStr.Replace("urn:com", "urn");
                        XmlDocument rspXml = new XmlDocument();
                        rspXml.LoadXml(responseStr);
                        msRsp = CommunicationUtil.ConvertXmlDocumentToMemoryStream(rspXml);
                    }
                }

                // Deserialize Response [objXML] to [obj]
                rspobj = (ResponseT)XMLSerializer.DeSerialize(msRsp, typeof(ResponseT));
                if (NeedPrintMessageToConsole)
                {
                    Console.WriteLine("-----------Response:-----------");
                    Print.PrintMessageToConsole(rspobj);
                }
            }
            return(rspobj);
        }
        /*
         * public static string FormatRequest(MemoryStream ms, MessageFormat.MessageContentType messageContentType = MessageFormat.MessageContentType.Xml, MessageMode messageMode = MessageMode.Serialize)
         * {
         *  string strRequest = "";
         *  MemoryStream outMS;
         *  if (messageMode == MessageMode.Serialize)
         *  {
         *      outMS = MessageFormat.Serialize(ms, messageContentType);
         *  }
         *  else
         *  {
         *      outMS = MessageFormat.Deserialize(ms, messageContentType);
         *  }
         *
         *  return strRequest;
         * }
         *
         * public static WebRequest getWebRequest(string strRequest, string uri, MessageFormat.MessageContentType messageContentType = MessageFormat.MessageContentType.Xml,
         *  MsgProtocol msgProtocol = MsgProtocol.Interop, bool withE3JRequestHeader = true)
         * {
         *  WebRequest webRequest = WebRequest.Create(uri);
         *  byte[] byteArray = Encoding.UTF8.GetBytes(strRequest);
         *  webRequest.Method = "POST";
         *  webRequest.ContentType = getContextType(messageContentType, msgProtocol);
         *  webRequest.ContentLength = byteArray.Length;
         *
         *
         *  if (withE3JRequestHeader)
         *  {
         *      // E3JMS-L-origServerName
         *      webRequest.Headers.Add("E3JMS-L-origServerName", Environment.MachineName);
         *
         *      // E3JMS-L-serviceName
         *      webRequest.Headers.Add("E3JMS-L-serviceName", System.Diagnostics.Process.GetCurrentProcess().ProcessName);
         *
         *      // e3jms-l-stand-rep
         *      webRequest.Headers.Add("e3jms-l-stand-rep", "TQ:e3Interop");
         *
         *      // E3JMS-L-activityId
         *      Guid guid = Guid.NewGuid();
         *      webRequest.Headers.Add("e3jms-l-activityId-propname", "activityId");
         *      webRequest.Headers.Add("E3JMS-L-activityId", Convert.ToString(guid));
         *
         *      // E3JMS-L-stand-mes
         *      String messageId = Convert.ToString(guid) + "-" + Guid.NewGuid();
         *      webRequest.Headers.Add("E3JMS-L-stand-mes", messageId);
         *  }
         *
         *  // Get the request stream.
         *  Stream dataStream = webRequest.GetRequestStream();
         *  // Write the data to the request stream.
         *  dataStream.Write(byteArray, 0, byteArray.Length);
         *  // Close the Stream object.
         *  dataStream.Close();
         *  return webRequest;
         * }*/


        public static ResponseT webSend <RequestT, ResponseT>(RequestT requestObj, CommunicationInformation comInfo, string originalGUID = null)
        {
            if (requestObj == null)
            {
                throw new ArgumentNullException("reqObj is null.");
            }

            if (comInfo == null)
            {
                throw new ArgumentNullException("commInfo is null.");
            }
            WebRequest request = WebRequest.Create(comInfo.URI);

            string    strRequest = TransferTypeUtil.ObjToStr(requestObj);
            ResponseT responseObj;

            if (NeedPrintMessageToConsole)
            {
                Console.WriteLine("========== Print Request ==========");
                Console.WriteLine(strRequest);
            }
            byte[] byteArray = Encoding.UTF8.GetBytes(strRequest);
            request.Method        = "POST";
            request.ContentType   = getContextType(comInfo.ContentType, comInfo.MessageProtocol);
            request.ContentLength = byteArray.Length;
            //If originalGUID is not null, use it
            //Otherwise if need spoofer, get OriginalGUID by TestCaseID; otherwise, generate a new GUID
            if (Convert.ToBoolean(CarConfigurationManager.AppSetting("NeedSpoofer")) == true)
            {
                uint nTestCaseID = CarCommonRequestGenerator.getTUIDFromRequest(requestObj);
                /// add by v-pxie 2013-11-22: support for the GUID list with one TUID
                string requestTypeName = requestObj.GetType().Name;
                originalGUID = EmbededFileOperation.getGUIDFromEmbededFile(nTestCaseID);
            }
            else if (originalGUID == null || originalGUID.Length == 0)
            {
                originalGUID = Guid.NewGuid().ToString();
            }

            //add OriginalGUID in request header
            request.Headers.Add("e3jms-l-activityId-propname", "activityId");
            request.Headers.Add("E3JMS-L-activityId", originalGUID);

            // Get the request stream.
            Stream dataStream = request.GetRequestStream();

            // Write the data to the request stream.
            dataStream.Write(byteArray, 0, byteArray.Length);
            // Close the Stream object.
            dataStream.Close();
            // Get the response.
            WebResponse response = request.GetResponse();

            // Display the status.
            Console.WriteLine("Response.StatusDescription=" + ((HttpWebResponse)response).StatusDescription);
            // Get the stream containing content returned by the server.
            try
            {
                dataStream = response.GetResponseStream();
                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader(dataStream);
                // Read the content.
                string responseFromServer = reader.ReadToEnd();
                // Display the content.
                if (NeedPrintMessageToConsole)
                {
                    Console.WriteLine("========== Print Response ==========");
                    if (null != responseFromServer)
                    {
                        Console.WriteLine(responseFromServer);
                    }
                }
                // Clean up the streams.
                reader.Close();
                dataStream.Close();
                response.Close();

                responseObj = (ResponseT)TransferTypeUtil.strToObj(responseFromServer, typeof(ResponseT));
                return(responseObj);
            }
            catch (Exception ex)
            {
                throw new Exception("Transport failed " + ex.ToString());
            }
        }
예제 #10
0
        public static MemoryStream DeSerialize(MemoryStream ms)
        {
            if (ms == null || ms.Length == 0)
            {
                throw new ArgumentNullException("ms");
            }

            ms.Seek(0, SeekOrigin.Begin);

            //Log the response before deserializing for debugging.
            bool needPrintMsg = false;

            if (null != CarConfigurationManager.AppSetting("NeedPrintResponseBeforeDeserialize"))
            {
                needPrintMsg = Boolean.Parse(CarConfigurationManager.AppSetting("NeedPrintResponseBeforeDeserialize"));
            }
            if (needPrintMsg)
            {
                Console.WriteLine(TransferTypeUtil.ObjToStr(ms));
            }

            XmlDocument doc = new XmlDocument();

            using (XmlReader reader = XmlFastInfosetReader.Create(ms))
            {
                doc.Load(reader);
            }

            //TODO: below handling is just to unblock testing, need to delete later to defect the DateTime handling bug
            //Delete the time in MinDate and MaxDate to unblock testing
            XmlNodeList minDateNodeList = doc.GetElementsByTagName("ns2:MinDate");
            XmlNodeList maxDateNodeList = doc.GetElementsByTagName("ns2:MaxDate");

            if (null != minDateNodeList && minDateNodeList.Count > 0)
            {
                foreach (XmlNode minDateNode in minDateNodeList)
                {
                    minDateNode.InnerText = minDateNode.InnerText.Substring(0, 10);
                }
            }
            if (null != maxDateNodeList && maxDateNodeList.Count > 0)
            {
                foreach (XmlNode maxDateNode in maxDateNodeList)
                {
                    maxDateNode.InnerText = maxDateNode.InnerText.Substring(0, 10);
                }
            }
            //Update 24:00 to 23:59 to unblock testing
            XmlNodeList minTimeNodeList = doc.GetElementsByTagName("ns2:MinTime");
            XmlNodeList maxTimeNodeList = doc.GetElementsByTagName("ns2:MaxTime");

            if (null != maxTimeNodeList && maxTimeNodeList.Count > 0)
            {
                foreach (XmlNode maxTimeNode in maxTimeNodeList)
                {
                    string maxTime = maxTimeNode.InnerText;
                    maxTime = maxTime.Replace("24:00", "23:59");
                    maxTimeNode.InnerText = maxTime;
                }
            }
            if (null != minTimeNodeList && minTimeNodeList.Count > 0)
            {
                foreach (XmlNode minTimeNode in minTimeNodeList)
                {
                    string minTime = minTimeNode.InnerText;
                    minTime = minTime.Replace("24:00", "23:59");
                    minTimeNode.InnerText = minTime;
                }
            }


            MemoryStream msDeserialized = new MemoryStream();

            using (XmlWriter writer = XmlWriter.Create(msDeserialized))
            {
                doc.WriteContentTo(writer);
                writer.Flush();
                writer.Close();
            }

            msDeserialized.Seek(0L, SeekOrigin.Begin);
            return(msDeserialized);
        }
        public static Double GetCurrencyConversionRateSend(String baseCurCode, String targetCurCode)
        {
            if (baseCurCode == null)
            {
                throw new ArgumentNullException("baseCurCode");
            }

            if (targetCurCode == null)
            {
                throw new ArgumentNullException("targetCurCode");
            }

            Double exchangeRate = -1.00; // error value

            XmlDocument docRequest = new XmlDocument();
            string      xmlStr     = "" + //"<?xml version='1.0' encoding='utf-8'?>\r\n" +
                                     "<s:Envelope " +
                                     "xmlns:s='http://www.w3.org/2003/05/soap-envelope' " +
                                     "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " +
                                     "xmlns:xsd='http://www.w3.org/2001/XMLSchema'>\r\n" +
                                     "</s:Envelope>";

            try
            {
                docRequest.LoadXml(xmlStr);

                //Get root element
                XmlElement envelope = docRequest.DocumentElement;

                // Create body
                XmlElement body = docRequest.CreateElement("s", "Body", "http://www.w3.org/2003/05/soap-envelope");
                body.InnerXml = FxRatesRequestTemplate();
                envelope.AppendChild(body);

                // Set DateTime
                String  currentDate    = DateTime.Now.ToString("o");
                XmlNode createDateTime = docRequest.GetElementsByTagName("urn:CreateDateTime")[0];
                createDateTime.InnerXml = currentDate;

                // Set BaseCurrencyCode
                XmlNode baseCurrencyCode = docRequest.GetElementsByTagName("urn:BaseCurrencyCode")[0];
                baseCurrencyCode.InnerXml = baseCurCode;

                // Set TargetCurrencyCode
                XmlNode targetCurrencyCode = docRequest.GetElementsByTagName("urn:TargetCurrencyCode")[0];
                targetCurrencyCode.InnerXml = targetCurCode;

                // Send/Recv
                String fxRsUri = CarConfigurationManager.AppSetting("FXRSUri");
                CommunicationInformation commInfo = new CommunicationInformation(fxRsUri, MsgProtocol.SOAP, MessageFormat.MessageContentType.Xml, MessageEncodeDecode.MessageContentEncoding.gzip, false);

                HttpWebResponse rsp   = CommunicationManager.SendReqAndRecvResp(CommunicationUtil.ConvertXmlDocumentToMemoryStream(docRequest), commInfo);
                MemoryStream    msRsp = CommunicationUtil.StreamToMemoryStream(rsp.GetResponseStream());
                msRsp.Seek(0, SeekOrigin.Begin);

                // Load Response in doc
                XmlDocument docResponse = new XmlDocument();
                docResponse.Load(msRsp);

                // Extract exchange rate
                XmlNode rate = null;
                if (docResponse.GetElementsByTagName("Rate", "urn:expedia:xmlapi:fxrs:v1").Count == 0)
                {
                    return(exchangeRate);
                }

                rate         = docResponse.GetElementsByTagName("Rate", "urn:expedia:xmlapi:fxrs:v1")[0];
                exchangeRate = Convert.ToDouble(rate.InnerXml);
            }
            catch (Exception e)
            {
                Console.WriteLine(string.Format("Error when sending FXRS for baseCurCode:{0}, targetCurCode: {1}. ", baseCurCode, targetCurCode));
                //throw e;
            }

            return(exchangeRate);
        }