private static AddressServiceResponse ShowAddressValidationReply(AddressValidationReply reply)
        {
            F21.Service.AddressServiceResponse addressResponse = new F21.Service.AddressServiceResponse();

            try
            {
                // AddressValidationReply details:
                foreach (AddressValidationResult result in reply.AddressResults)
                {
                    // FedExAddressClassificationType : BUSINESS, MIXED, RESIDENTIAL, UNKNOWN
                    // System.Diagnostics.Debug.WriteLine("Address Id : " + result.ClientReferenceId);

                    addressResponse.ClientReferenceId = result.ClientReferenceId;

                    if (result.ClassificationSpecified)
                    {
                        //System.Diagnostics.Debug.WriteLine("Classification: " + result.Classification);
                        addressResponse.Classification = result.Classification.ToString();
                    }


                    if (result.StateSpecified)
                    {
                        //System.Diagnostics.Debug.WriteLine("State: " + result.State);
                        addressResponse.OperationalAddressStateType = result.State.ToString();
                    }

                    //System.Diagnostics.Debug.WriteLine("Proposed Address--");

                    Address address = result.EffectiveAddress;


                    foreach (String street in address.StreetLines)
                    {
                        System.Diagnostics.Debug.WriteLine("   Street: " + street);
                    }

                    if (address.StreetLines != null)
                    {
                        addressResponse.CustomerStreetLines = new string[address.StreetLines.Length];

                        for (int i = 0; i < address.StreetLines.Length; i++)
                        {
                            addressResponse.CustomerStreetLines[i] = address.StreetLines[i];
                        }
                    }

                    System.Diagnostics.Debug.WriteLine("     City: " + address.City);
                    System.Diagnostics.Debug.WriteLine("    ST/PR: " + address.StateOrProvinceCode);
                    System.Diagnostics.Debug.WriteLine("   Postal: " + address.PostalCode);
                    System.Diagnostics.Debug.WriteLine("  Country: " + address.CountryCode);
                    System.Diagnostics.Debug.WriteLine("");

                    addressResponse.City = address.City;
                    addressResponse.StateOrProvinceCode = address.StateOrProvinceCode;
                    addressResponse.PostalCode          = address.PostalCode;
                    addressResponse.CountryCode         = address.CountryCode;

                    System.Diagnostics.Debug.WriteLine("Address Attributes:");
                    foreach (AddressAttribute attribute in result.Attributes)
                    {
                        // Check Attributes
                        System.Diagnostics.Debug.WriteLine("  " + attribute.Name + ": " + attribute.Value);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(addressResponse);
        }
        public AddressServiceResponse ValidationServiceClient(ShipServiceInfo clsService, AddressInfo clsAddress)
        {
            string ClassificationType = string.Empty;
            string serviceURL         = string.Empty;

            AddressValidationService service = new AddressValidationService();

            F21.Service.AddressServiceResponse fedExResponse = new F21.Service.AddressServiceResponse();

            try
            {
                if (F21.Framework.ConfigManager.GetAppSetting2("mode").Equals("production", StringComparison.OrdinalIgnoreCase))
                {
                    serviceURL = F21.Framework.ConfigManager.GetAppSetting2("Live_FedExAddressUrl");
                }
                else
                {
                    serviceURL = F21.Framework.ConfigManager.GetAppSetting2("Test_FedExAddressUrl");
                }


                if (string.IsNullOrEmpty(serviceURL))
                {
                    fedExResponse.isSuccess    = false;
                    fedExResponse.ErrorMessage = "Address validation service url is empty.";

                    return(fedExResponse);
                }

                AddressValidationRequest request = CreateAddressValidationRequest(clsService, clsAddress);

                // Test URL : https://wsbeta.fedex.com:443/web-services/addressvalidation
                service.Url = serviceURL;

                AddressValidationReply reply = service.addressValidation(request);

                if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING)
                {
                    //FedExAddressClassificationType Enum
                    fedExResponse = ShowAddressValidationReply(reply);

                    fedExResponse.HighestSeverity = reply.HighestSeverity.ToString();
                    fedExResponse.isSuccess       = true;
                    fedExResponse.ErrorMessage    = "";
                }
                else
                {
                    fedExResponse.HighestSeverity = reply.HighestSeverity == null ? "" : reply.HighestSeverity.ToString();
                    fedExResponse.isSuccess       = false;

                    foreach (Notification notification in reply.Notifications)
                    {
                        System.Diagnostics.Debug.WriteLine(notification.Message);
                        fedExResponse.ErrorMessage = notification.Message;
                    }
                }
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                throw ex;
            }
            catch (System.ServiceModel.CommunicationException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(fedExResponse);
        }