Пример #1
0
        public Decimal GetMileage(string originPostalCode, string destinationPostalCode)
        {
            //
            Decimal miles = 0;
            RateWareXLPortTypeClient client = new RateWareXLPortTypeClient();

            try {
                AuthenticationToken authToken = getAuthenticationToken();
                if (client.isReady(authToken))
                {
                    ShipmentLocale org = new ShipmentLocale();
                    org.postalCode  = originPostalCode;
                    org.countryCode = "USA";

                    ShipmentLocale dest = new ShipmentLocale();
                    dest.postalCode  = destinationPostalCode;
                    dest.countryCode = "USA";

                    Mileage mileage = new Mileage();
                    mileage.releaseVersion = "22";
                    mileage.routingType    = "P";
                    mileage.systemId       = 1;
                    mileage.origin         = org;
                    mileage.destination    = dest;

                    miles = (Decimal)client.Mileage(authToken, mileage);
                }
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(miles);
        }