예제 #1
1
        private static string BuildVoidShipRequest(ref VoidShipmentRequest req)
        {

            StringWriter strWriter = new StringWriter();
            XmlTextWriter xw = new XmlTextWriter(strWriter);

            xw.Formatting = Formatting.Indented;
            xw.Indentation = 3;

            xw.WriteStartDocument();

            //--------------------------------------------            
            // Start Void Shipment Request
            xw.WriteStartElement("VoidShipmentRequest");

            //--------------------------------------------
            // Request
            xw.WriteStartElement("Request");
            //--------------------------------------------
            // TransactionReference
            xw.WriteStartElement("TransactionReference");
            xw.WriteElementString("CustomerContext", "Void Shipment Request");
            xw.WriteElementString("XpciVersion", "1.0001");
            xw.WriteEndElement();
            // End TransactionReference
            //--------------------------------------------
            xw.WriteElementString("RequestAction", "1");
            xw.WriteElementString("RequestOption", "");
            xw.WriteEndElement();
            // End Request
            //--------------------------------------------

            xw.WriteElementString("ShipmentIdentificationNumber", req.ShipmentIdentificationNumber);

            xw.WriteEndElement();
            // End Void Shipment Request
            //--------------------------------------------

            xw.WriteEndDocument();
            xw.Flush();
            xw.Close();


            // Output Xml As String with Access Key
            string sXML = "";
            sXML = XmlTools.BuildAccessKey(req.Settings);
            sXML += "\n";
            sXML += strWriter.GetStringBuilder().ToString();

            return sXML;
        }
예제 #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;
        }