Exemple #1
0
        private static VoidShipmentResponse ParseVoidShipmentResponse(string xml)
        {
            VoidShipmentResponse result = new VoidShipmentResponse();

            try
            {
                XmlDocument xDoc;
                xDoc = new XmlDocument();
                xDoc.LoadXml(xml);

                XmlNode nodeResponseCode = xDoc.SelectSingleNode("VoidShipmentResponse/Response/ResponseStatusCode");
                if (nodeResponseCode != null)
                {
                    int responseCode = 0;
                    responseCode = int.Parse(nodeResponseCode.InnerText);
                    if (responseCode == 1)
                    {
                        result.Success = true;
                    }
                    else
                    {
                        result.Success = false;

                        // Parse error
                        result.ErrorMessage = XmlTools.XPathToString(ref xDoc, "VoidShipmentResponse/Response/Error/ErrorDescription");

                    }
                }
                else
                {
                    result.Success = false;
                    result.ErrorMessage = "Unable to Parse Response Code.";
                }
            }

            catch (Exception Exx)
            {
                result.ErrorMessage = "Parsing Error: " + Exx.Message;
                result.Success = false;
            }

            return result;
        }
Exemple #2
0
        public static VoidShipmentResponse SendVoidShipmentRequest(ref VoidShipmentRequest req)
        {
            VoidShipmentResponse result = new VoidShipmentResponse();

            // Build Request and save output
            string requestXml = BuildVoidShipRequest(ref req);
            req.XmlRequest = requestXml;

            // Build Url for UPS Service
            string actionUrl = req.Settings.ServerUrl;
            actionUrl += "Void";

            // Send Request and Store Response
            string responseXml = string.Empty;
            responseXml = XmlTools.ReadHtmlPage_POST(actionUrl, requestXml);
            req.XmlResponse = responseXml;

            // Parse Response
            result = ParseVoidShipmentResponse(responseXml);

            return result;
        }