Beispiel #1
0
        private static string BuildShipAcceptRequest(ref ShipAcceptRequest req)
        {

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

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

            xw.WriteStartDocument();

            //--------------------------------------------            
            // Start Shipment Accept Request
            xw.WriteStartElement("ShipmentAcceptRequest");

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

            xw.WriteElementString("ShipmentDigest", req.ShipDigest);

            xw.WriteEndElement();
            // End Shipment Accept 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;
        }
Beispiel #2
0
        public static ShipAcceptResponse SendShipAcceptRequest(ref ShipAcceptRequest req)
        {
            ShipAcceptResponse result = new ShipAcceptResponse();

            // Build Request and save output
            string requestXml = BuildShipAcceptRequest(ref req);
            req.XmlAcceptRequest = requestXml;

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

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

            // Parse Response
            result = ParseShipAcceptResponse(responseXml);

            return result;
        }