{"id":769,"date":"2022-03-21T15:47:38","date_gmt":"2022-03-21T06:47:38","guid":{"rendered":"https:\/\/uapisupport.travelport.co.kr\/?page_id=769"},"modified":"2022-03-22T10:37:38","modified_gmt":"2022-03-22T01:37:38","slug":"c-soap-client-%ec%83%98%ed%94%8c","status":"publish","type":"page","link":"https:\/\/uapisupport.travelport.co.kr\/?page_id=769","title":{"rendered":"C# Soap Client \uc0d8\ud50c"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Remark : uAPI Soap Call and Parsing sample C#<\/h3>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:c# decode:true \" title=\"Main\">using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Xml;\n\nnamespace uAPICoreConsole\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls | System.Net.SecurityProtocolType.Tls12;\n\n            string EndPoint = \"https:\/\/apac.universal-api.pp.travelport.com\/B2BGateway\/connect\/uAPI\/AirService\";\n            string credentials = \"*******************\";\n            string Password = \"*******j\";\n\n            string SoapRequest = @\"&lt;soapenv:Envelope xmlns:soapenv = 'http:\/\/schemas.xmlsoap.org\/soap\/envelope\/'\" + \n\"    \t\t\t\t\t\t  xmlns:air='http:\/\/www.travelport.com\/schema\/air_v50_0' \" +\n\"    \t\t\t\t\t\t  xmlns:com='http:\/\/www.travelport.com\/schema\/common_v50_0'&gt;\" +\n\"  &lt;soapenv:Body&gt;\" +\n\"    &lt;air:LowFareSearchReq TraceId='2021122918322322'  TargetBranch='P*******' SolutionResult='true' AuthorizedBy='user' &gt;\" +\n\"      &lt;com:BillingPointOfSaleInfo OriginApplication='UAPI'\/&gt;\" +\n\"      &lt;air:SearchAirLeg&gt;\" +\n\"        &lt;air:SearchOrigin&gt;\" +\n\"          &lt;com:CityOrAirport  Code='DEL'\/&gt;\" +\n\"        &lt;\/air:SearchOrigin&gt;\" +\n\"        &lt;air:SearchDestination&gt;\" +\n\"          &lt;com:CityOrAirport  Code='BOM'\/&gt;\" +\n\"        &lt;\/air:SearchDestination&gt;\" +\n\"        &lt;air:SearchDepTime PreferredTime='2022-05-12'&gt; &lt;\/air:SearchDepTime&gt;\" +\n\"      &lt;\/air:SearchAirLeg&gt;\" +\n\"  &lt;air:AirSearchModifiers&gt;\" +\n\"    &lt;air:PreferredProviders&gt;\" +\n\"      &lt;com:Provider Code='1G' \/&gt;\" +\n\"    &lt;\/air:PreferredProviders&gt;\" +\n\"    &lt;air:PermittedCarriers&gt;\" +\n\"      &lt;com:Carrier Code='AI' \/&gt;\" +\n\"    &lt;\/air:PermittedCarriers&gt;\" +\n\"    &lt;air:PreferredCabins&gt;\" +\n\"      &lt;com:CabinClass Type='Economy' \/&gt;\" +\n\"    &lt;\/air:PreferredCabins&gt;\" +\n\"    &lt;air:FlightType  NonStopDirects='true' StopDirects='true' SingleOnlineCon='true' DoubleOnlineCon='false' TripleOnlineCon='false' SingleInterlineCon='false' DoubleInterlineCon='false' TripleInterlineCon='false' \/&gt;\" +\n\"  &lt;\/air:AirSearchModifiers&gt;\" +\n\"     &lt;com:SearchPassenger Code='ADT'\/&gt;\" +\n\"      &lt;air:AirPricingModifiers ETicketability='Required' FaresIndicator='AllFares'\/&gt;\" +\n\"    &lt;\/air:LowFareSearchReq&gt;\" +\n\"  &lt;\/soapenv:Body&gt;\" +\n\"&lt;\/soapenv:Envelope&gt;\";\n\n            string Res = string.Empty;\n\n            try\n            {\n                SoapClass SC = new SoapClass();\n                Res = SC.CallWebService(1, EndPoint, SoapRequest, credentials, Password);\n                SC = null;\n            }\n            catch (Exception ex)\n            {\n                Res = ex.Message.ToString();\n                Res = \"&lt;ERR&gt;\" + Res + \"&lt;\/ERR&gt;\";\n            }\n            \/\/Console.WriteLine(Res);\n\n            XmlDocument doc = new XmlDocument();\n            XmlNodeList nodeList;\n\n            doc.LoadXml(Res);\n\n            XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);\n            nsmgr.AddNamespace(\"common_v50_0\", \"http:\/\/www.travelport.com\/schema\/common_v50_0\");\n            nsmgr.AddNamespace(\"air\", \"http:\/\/www.travelport.com\/schema\/air_v50_0\");\n\n            XmlNode root = doc.DocumentElement;\n\n            nodeList = doc.SelectNodes(\"\/\/air:AirPricingSolution\", nsmgr);\n\n            if (nodeList.Count &gt; 0)\n            {\n                foreach (XmlNode DATA in nodeList)\n                {\n                    Console.WriteLine(\"key: {0}\", DATA.Attributes[\"Key\"].Value);\n                    Console.WriteLine(\"ApproximateTotalPrice: {0}\", DATA.Attributes[\"ApproximateTotalPrice\"].Value);\n                    Console.WriteLine(\"PlatingCarrier: {0}\", DATA.SelectSingleNode(\"air:AirPricingInfo\", nsmgr).Attributes[\"PlatingCarrier\"].Value);\n                }\n            }\n\n            Console.ReadLine();\n        }\n}<\/pre><\/div>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:c# decode:true \" title=\"SoapClass\">using System;\nusing System.Text;\nusing System.Xml;\nusing System.Net;\nusing System.IO;\n\nnamespace uAPICoreConsole\n{\n    class SoapClass\n    {\n        public string CallWebService(int ServerType, string EndPoint, string SoapData, string credentials, string Password)\n        {\n            var _action = EndPoint;\n\n            XmlDocument soapEnvelopeXml = CreateSoapEnvelope(SoapData);\n            HttpWebRequest webRequest = CreateWebRequest(ServerType, _action, credentials, Password);\n            InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest);\n\n            \/\/ begin async call to web request.\n            IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null);\n\n            \/\/ suspend this thread until call is complete. You might want to\n            \/\/ do something usefull here like update your UI.\n            asyncResult.AsyncWaitHandle.WaitOne(); \/\/\uc8fc\uc11d\ucc98\ub9ac\n\n            \/\/ get the response from the completed web request.\n            string soapResult;\n            using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))\n            {\n                using (StreamReader rd = new StreamReader(webResponse.GetResponseStream()))\n                {\n                    soapResult = rd.ReadToEnd();\n                }\n            }\n            return soapResult;\n        }\n\n        private HttpWebRequest CreateWebRequest(int ServerType, string action, string credentials, string Password)\n        {\n\n            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(action); \/\/action \uc0ac\uc6a9\n            \/\/webRequest.Headers.Add(\"SOAPAction\", action); \/\/\uc544\ub798\uc544 \uac19\uc774 \uc218\uc815 \n            webRequest.Headers.Add(\"Authorization\", \"Basic \" + Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials + \":\" + Password)));\n            webRequest.ContentType = \"text\/xml;charset=\\\"utf-8\\\"\";\n            webRequest.Accept = \"text\/xml\";\n            webRequest.Method = \"POST\";\n\n            return webRequest;\n        }\n\n        private XmlDocument CreateSoapEnvelope(string SoapData)\n        {\n            XmlDocument soapEnvelop = new XmlDocument();\n            soapEnvelop.LoadXml(SoapData);\n            return soapEnvelop;\n        }\n\n        private void InsertSoapEnvelopeIntoWebRequest(XmlDocument soapEnvelopeXml, HttpWebRequest webRequest)\n        {\n            using (Stream stream = webRequest.GetRequestStream())\n            {\n                soapEnvelopeXml.Save(stream);\n            }\n        }\n\n    }\n}<\/pre><\/div>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"theme:vs2012-black lang:vim decode:true \" title=\"Console.Writeline\">key: zmZ1Y++pWDKAQtfLBAAAAA==\nApproximateTotalPrice: KRW46600\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKAntfLBAAAAA==\nApproximateTotalPrice: KRW46600\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKAxtfLBAAAAA==\nApproximateTotalPrice: KRW46600\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKA7tfLBAAAAA==\nApproximateTotalPrice: KRW46600\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKAFufLBAAAAA==\nApproximateTotalPrice: KRW46600\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKAPufLBAAAAA==\nApproximateTotalPrice: KRW46600\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKAaufLBAAAAA==\nApproximateTotalPrice: KRW46600\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKAbufLBAAAAA==\nApproximateTotalPrice: KRW71200\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKA6ufLBAAAAA==\nApproximateTotalPrice: KRW72600\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKAYvfLBAAAAA==\nApproximateTotalPrice: KRW72600\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKAZvfLBAAAAA==\nApproximateTotalPrice: KRW74100\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKArvfLBAAAAA==\nApproximateTotalPrice: KRW80200\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKA9vfLBAAAAA==\nApproximateTotalPrice: KRW81400\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKA+vfLBAAAAA==\nApproximateTotalPrice: KRW91300\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKAQwfLBAAAAA==\nApproximateTotalPrice: KRW91500\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKAuwfLBAAAAA==\nApproximateTotalPrice: KRW91500\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKA5wfLBAAAAA==\nApproximateTotalPrice: KRW91500\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKA6wfLBAAAAA==\nApproximateTotalPrice: KRW95200\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKAYxfLBAAAAA==\nApproximateTotalPrice: KRW96500\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKAqxfLBAAAAA==\nApproximateTotalPrice: KRW101000\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKArxfLBAAAAA==\nApproximateTotalPrice: KRW107400\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKAHyfLBAAAAA==\nApproximateTotalPrice: KRW107400\nPlatingCarrier: AI\nkey: zmZ1Y++pWDKAIyfLBAAAAA==\nApproximateTotalPrice: KRW120300\nPlatingCarrier: AI\n<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Remark : uAPI Soap Call and Parsing sample C#<\/p>\n","protected":false},"author":4,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-769","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/uapisupport.travelport.co.kr\/index.php?rest_route=\/wp\/v2\/pages\/769","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/uapisupport.travelport.co.kr\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/uapisupport.travelport.co.kr\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/uapisupport.travelport.co.kr\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/uapisupport.travelport.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=769"}],"version-history":[{"count":3,"href":"https:\/\/uapisupport.travelport.co.kr\/index.php?rest_route=\/wp\/v2\/pages\/769\/revisions"}],"predecessor-version":[{"id":774,"href":"https:\/\/uapisupport.travelport.co.kr\/index.php?rest_route=\/wp\/v2\/pages\/769\/revisions\/774"}],"wp:attachment":[{"href":"https:\/\/uapisupport.travelport.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=769"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}