public static DHLResponse XmlResponse(string respString, REQUESTS reqType) { DHLResponse resp = new DHLResponse(); switch (reqType) { case REQUESTS.CAPABILITY: resp.Quote = ParseXmlCapability(respString); break; case REQUESTS.IMAGE_UPLOAD: break; case REQUESTS.PICKUP: break; case REQUESTS.ROUTING: break; case REQUESTS.SHIPMENT: break; case REQUESTS.TRACKING: resp.Trackings = ParseXmlTracking(respString); break; default: break; } resp.RequestType = reqType; return(resp); }
static void Main(string[] args) { //DHLApi api = new DHLApi(); string url = ConfigurationManager.AppSettings["DHLWebApi"]; //string xmlFile = "TrackingRequest_SingleAWB_10D.xml"; //string xmlFile = "TrackingRequest_MultipleLP_PieceEnabled_B_1.xml"; //string xmlFile = "Shipment_Global_AP_RegularShpmt_Request.xml"; //string xmlFile = "Request.xml"; //string xmlFile = "BookPickup_GlobalAP_Valid1_Request.xml"; //string xmlFile = "Valid15_Quote_VolWeightHigher_Request.xml"; //string xmlFile = "Valid13_Quote_IMPPricebyReceiver_Request.xml"; string xmlFile = "Valid10_Quote_AP_PriceBreakdownRAS_Request.xml"; //string xmlFile = "Valid11_Quote_EU_PriceBreakdownRAS_Request.xml"; //string xmlFile = "Valid14_Quote_IMPPriceby3rdParty_Request.xml"; //string xmlFile = "Valid17_Quote_EU_NonEU_WithAcctProdInsurance_Request.xml"; //string xmlFile = "Valid18_Quote_BRtoUS_Request.xml"; //string xmlFile = "Valid19_Quote_PEtoEG_Suburb_Request.xml"; //string xmlFile = "Valid20_Quote_BRtoBR_TaxBreakdownPricing_Request.xml"; //string xmlFile = "Valid3_Capability_EU_NonEU_Dutiable_Request.xml"; //string xmlFile = "Valid3_Capability_EU_NonEU_Dutiable_Request.xml"; #if false string filePath = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath(@"~/DHLShippingXml/"), xmlFile); #else string filePath = Path.Combine(Environment.CurrentDirectory + @"/DHLShippingXml/", xmlFile); #endif // Setup RequestQuote object RequestBase requestQuote = new RequestQuote { RequestType = REQUESTS.CAPABILITY, Origin = new CountryPostalCode() { CountryCode = "BE", Postalcode = "1020", City = "Lima" }, BkgDetails = new BkgDetails() { PaymentCountryCode = "BE", Date = "2017-08-27", ReadyTime = "PT10H22M", ReadyTimeGMTOffset = "+02:00", DimensionUnit = "CM", WeightUnit = "KG", Pieces = new List <Piece>() { new Piece() { PieceID = 1, Height = 30, Depth = 20, Width = 10, Weight = 1.0f, }, new Piece() { PieceID = 2, Height = 60, Depth = 40, Width = 20, Weight = 2.0f, } }, IsDutiable = "Y", NetworkTypeCode = "AL", QtdShp = new QtdShp() { LocalProductCode = "S", QtdShpExChrg_SpecialServiceType = "I", QtdShpExChrg_LocalSpecialServiceType = "II" }, InsuredValue = "400.000", InsuredCurrency = "EUR", }, Destination = new CountryPostalCode() { CountryCode = "US", Postalcode = "86001" }, Dutiable = new Dutiable() { DeclaredCurrency = "EUR", DeclaredValue = "9.0" } }; // Setup RequestTracking object RequestBase requestTracking = new RequestTracking() { RequestType = REQUESTS.TRACKING, LanguageCode = "en", Waybill = "5093841045", //LPNumber = "JD0144549751510007712", LevelOfDetails = "ALL_CHECK_POINTS", PiecesEnabled = "B" }; #if true DHLApi.SetupRequest(filePath, requestQuote); DHLApi.XmlRequest(url, filePath); DHLResponse resp = DHLApi.XmlResponse(DHLApi.ResponseXmlString, REQUESTS.CAPABILITY); #else DHLApi.SetupRequest(filePath, requestTracking); DHLApi.XmlRequest(url, filePath); DHLResponse resp = DHLApi.XmlResponse(DHLApi.ResponseXmlString, REQUESTS.TRACKING); #endif if (resp.RequestType == REQUESTS.TRACKING) { OutputTrackingResponse(resp.Trackings); } else { OutputQuoteResponse(resp.Quote); } }