static void Main(string[] args) { AddressValidationRequest request = CreateAddressValidationRequest(); // AddressValidationService service = new AddressValidationService(); if (usePropertyFile()) { service.Url = getProperty("endpoint"); } // try { // Call the AddressValidationService passing in an AddressValidationRequest and returning an AddressValidationReply AddressValidationReply reply = service.addressValidation(request); // if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING) { ShowAddressValidationReply(reply); } else { foreach (Notification notification in reply.Notifications) { Console.WriteLine(notification.Message); } } } catch (SoapException e) { Console.WriteLine(e.Detail.InnerText); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine("Press any key to quit!"); Console.ReadKey(); }
protected void FEDEX(Person p) { string straddress2 = p.Addr1; string strzipcode = p.Zip5; string address = string.Empty; string zipfour = string.Empty; string ststate = string.Empty; string zip = string.Empty; string[] split = null; string delimStr = "-"; char[] delimiter = delimStr.ToCharArray(); btn2Submit.Enabled = true; lblAVS_Shipping.Visible = false; AddressValidationRequest request = CreateAddressValidationRequest(straddress2, strzipcode); // AddressValidationService addressValidationService = new AddressValidationService(); // try { // This is the call to the web service passing in an AddressValidationRequest and returning an AddressValidationReply AddressValidationReply reply = addressValidationService.addressValidation(request); // int score = Convert.ToInt32(reply.AddressResults[0].ProposedAddressDetails[0].Score); if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING) { foreach (AddressValidationResult result in reply.AddressResults) { foreach (ProposedAddressDetail detail in result.ProposedAddressDetails) { address = detail.Address.StreetLines[0]; zip = detail.Address.PostalCode; split = zip.Split(delimiter); zip = split[0]; //zipfour = split[1]; } if (score < 20)//(split.Length<2) (zipfour == null || zipfour.Length < 4) { lblAVS_Shipping.Text = "Address Not Found (FedEx)"; btn2Submit.Enabled = false; lblAVS_Shipping.Visible = true; } else { lblAVS_Shipping.Text = "SUCCESS"; btn2Submit.Enabled = true; lblAVS_Shipping.Visible = false; } } } else { foreach (Notification notification in reply.Notifications) { lblAVS_Shipping.Text = notification.Message; } } } catch (Exception ex) { //yma add this since fedex return exception when no valid address found lblAVS_Shipping.Text = "Address Not Found (FedEx)"; btn2Submit.Enabled = false; lblAVS_Shipping.Visible = true; //Write to log Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry logEnt = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry(); logEnt.Message = "\r\n" + "FedEx Address Verification error." + "\r\n" + "Source: " + ex.Source + "\r\n" + "Description: " + ex.Message + "\r\n" + "Stack Trace: " + ex.StackTrace; Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(logEnt, "Logs"); } }
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); }
public string Result() { string FinalResult = "no"; bool isContrySupported = false; bool isResolved = false; AddressValidationRequest request = CreateAddressValidationRequest(); // AddressValidationService service = new AddressValidationService(); if (usePropertyFile()) { service.Url = getProperty("endpoint"); } // try { // Call the AddressValidationService passing in an AddressValidationRequest and returning an AddressValidationReply AddressValidationReply reply = service.addressValidation(request); // if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING) { //ShowAddressValidationReply(reply); foreach (AddressValidationResult result in reply.AddressResults) { //Console.WriteLine("Address Id : " + result.ClientReferenceId); // if (result.ClassificationSpecified) { Console.WriteLine("Classification: " + result.Classification); } // if (result.StateSpecified) { Console.WriteLine("State: " + result.State); } // Console.WriteLine("Proposed Address--"); // Address address = result.EffectiveAddress; // foreach (String street in address.StreetLines) // { // Console.WriteLine(" Street: " + street); // } // Console.WriteLine(" City: " + address.City); // Console.WriteLine(" ST/PR: " + address.StateOrProvinceCode); // Console.WriteLine(" Postal: " + address.PostalCode); // Console.WriteLine(" Country: " + address.CountryCode); // Console.WriteLine(); // Console.WriteLine("Address Attributes:"); foreach (AddressAttribute attribute in result.Attributes) { if (attribute.Name == "CountrySupported" && attribute.Value == "true") { isContrySupported = true; } else if (attribute.Name == "Resolved" && attribute.Value == "true") { isResolved = true; } //Console.WriteLine(" " + attribute.Name + ": " + attribute.Value); } } } else { // foreach (Notification notification in reply.Notifications) // Console.WriteLine(notification.Message); } } catch (SoapException e) { // Console.WriteLine(e.Detail.InnerText); } catch (Exception e) { // Console.WriteLine(e.Message); } // Console.WriteLine("Press any key to quit!"); //Console.ReadKey(); if (isContrySupported && isResolved) { FinalResult = "yes"; } return(FinalResult); }
protected void FEDEX(Person p) { string straddress2 = p.Addr1; string strzipcode = p.Zip5; string address = string.Empty; string zipfour = string.Empty; string ststate = string.Empty; string zip = string.Empty; string[] split = null; string delimStr = "-"; char[] delimiter = delimStr.ToCharArray(); //btn2Submit.Enabled = true; lblAVS_Shipping.Visible = false; this.divVerifyErrDisplay.Visible = false; AddressValidationRequest request = CreateAddressValidationRequest(straddress2, strzipcode); // AddressValidationService addressValidationService = new AddressValidationService(); // try { // This is the call to the web service passing in an AddressValidationRequest and returning an AddressValidationReply AddressValidationReply reply = addressValidationService.addressValidation(request); // int score = Convert.ToInt32(reply.AddressResults[0].ProposedAddressDetails[0].Score); if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING) { foreach (AddressValidationResult result in reply.AddressResults) { foreach (ProposedAddressDetail detail in result.ProposedAddressDetails) { address = detail.Address.StreetLines[0]; zip = detail.Address.PostalCode; split = zip.Split(delimiter); zip = split[0]; //zipfour = split[1]; } if (score < 20) //(split.Length<2) (zipfour == null || zipfour.Length < 4) { lblAVS_Shipping.Text = "Address Not Found"; //intentionally missing period so I can tell if its usps or fedex //btn2Submit.Enabled = false; lblAVS_Shipping.Visible = true; this.divVerifyErrDisplay.Visible = true; } else { lblAVS_Shipping.Text = "SUCCESS"; //btn2Submit.Enabled = true; lblAVS_Shipping.Visible = false; this.divVerifyErrDisplay.Visible = false; } } } else { foreach (Notification notification in reply.Notifications) { lblAVS_Shipping.Text = notification.Message; } } } catch (Exception ex) { } }