private RateResponse CallUPSRateRequest(string scode, int Qty, int nrBoxes, int itemsInLastBox, string fullBoxWeight, int valuePerFullBox, int valuePerPartialBox, string partialBoxWeight, inv_detl details, decimal unitPrice, RateService upsService)
        {
            RateResponse rateResponse = new RateResponse();
            try
            {
                RateRequest rateRequest = new RateRequest();
                AddCustomerClassification(rateRequest);
                AddUpsSecurity(upsService);
                UPS_Shipping_Rate.UPSRateService.RequestType request = new RequestType();
                String[] requestOption = { "Rate" };
                request.RequestOption = requestOption;
                rateRequest.Request = request;
                ShipmentType shipment = new ShipmentType();
                AddShipper(shipment);
                AddShipFromAddress(shipment);
                AddShipToAddress(shipment);
                UPS_Shipping_Rate.UPSRateService.CodeDescriptionType service = new UPS_Shipping_Rate.UPSRateService.CodeDescriptionType();
                service.Code = scode.ToString();
                shipment.Service = service;
                ShipmentRatingOptionsType optype = new ShipmentRatingOptionsType();
                optype.NegotiatedRatesIndicator = string.Empty;
                shipment.ShipmentRatingOptions = optype;
                AddPackageArray(nrBoxes, itemsInLastBox, fullBoxWeight, partialBoxWeight, valuePerFullBox, valuePerPartialBox, details, shipment);
                AddInvoiceTotalType(Qty, unitPrice, shipment);
                rateRequest.Shipment = shipment;
                //  ServicePointManager.ServerCertificateValidationCallback = ValidateRemoteCertificate;
                rateResponse = upsService.ProcessRate(rateRequest);
            }
            catch (Exception ex)
            {

            }
            return rateResponse;
        }
 /// <remarks/>
 public void ProcessRateAsync(RateRequest RateRequest, object userState)
 {
     if ((this.ProcessRateOperationCompleted == null))
     {
         this.ProcessRateOperationCompleted = new System.Threading.SendOrPostCallback(this.OnProcessRateOperationCompleted);
     }
     this.InvokeAsync("ProcessRate", new object[] {
                 RateRequest}, this.ProcessRateOperationCompleted, userState);
 }
 private void AddCustomerClassification(RateRequest rateRequest)
 {
     UPS_Shipping_Rate.UPSRateService.CodeDescriptionType customerType = new UPS_Shipping_Rate.UPSRateService.CodeDescriptionType();
     customerType.Code = "53";
     customerType.Description = "";
     rateRequest.CustomerClassification = customerType;
 }
 /// <remarks/>
 public void ProcessRateAsync(RateRequest RateRequest)
 {
     this.ProcessRateAsync(RateRequest, null);
 }