Problem with FedEx Address validation web service
- by DJ Matthews
Hi, I'm trying to get started with Fedex'es Address validation service and I'm running into a road block with FedEx's own demo application.
This is the code in there app:
Sub Main()
''# Build a AddressValidationRequest object
Dim request As AddressValidationRequest = New AddressValidationRequest()
Console.WriteLine("--- Setting Credentials ---")
request.WebAuthenticationDetail = New WebAuthenticationDetail()
request.WebAuthenticationDetail.UserCredential = New WebAuthenticationCredential()
request.WebAuthenticationDetail.UserCredential.Key = "###" ''# Replace "XXX" with the Key
request.WebAuthenticationDetail.UserCredential.Password = "###" ''# Replace "XXX" with the Password
Console.WriteLine("--- Setting Account Information ---")
request.ClientDetail = New ClientDetail()
request.ClientDetail.AccountNumber = "###" ''# Replace "XXX" with clients account number
request.ClientDetail.MeterNumber = "###" ''# Replace "XXX" with clients meter number
request.TransactionDetail = New TransactionDetail()
request.TransactionDetail.CustomerTransactionId = "Address Validation v2 Request using VB.NET Sample Code" ''# This is just an echo back
request.Version = New VersionId()
request.RequestTimestamp = DateTime.Now
Console.WriteLine("--- Setting Validation Options ---")
request.Options = New AddressValidationOptions()
request.Options.CheckResidentialStatus = True
request.Options.MaximumNumberOfMatches = 5
request.Options.StreetAccuracy = AddressValidationAccuracyType.LOOSE
request.Options.DirectionalAccuracy = AddressValidationAccuracyType.LOOSE
request.Options.CompanyNameAccuracy = AddressValidationAccuracyType.LOOSE
request.Options.ConvertToUpperCase = True
request.Options.RecognizeAlternateCityNames = True
request.Options.ReturnParsedElements = True
Console.WriteLine("--- Address 1 ---")
request.AddressesToValidate = New AddressToValidate(1) {New AddressToValidate(), New AddressToValidate()}
request.AddressesToValidate(0).AddressId = "WTC"
request.AddressesToValidate(0).Address = New Address()
request.AddressesToValidate(0).Address.StreetLines = New String(0) {"10 FedEx Parkway"}
request.AddressesToValidate(0).Address.PostalCode = "38017"
request.AddressesToValidate(0).CompanyName = "FedEx Services"
Console.WriteLine("--- Address 2 ---")
request.AddressesToValidate(1).AddressId = "Kinkos"
request.AddressesToValidate(1).Address = New Address()
request.AddressesToValidate(1).Address.StreetLines = New String(0) {"50 N Front St"}
request.AddressesToValidate(1).Address.PostalCode = "38103"
request.AddressesToValidate(1).CompanyName = "FedEx Kinkos"
Dim addressValidationService As AddressValidationService.AddressValidationService = New AddressValidationService.AddressValidationService
''#
Try
''# This is the call to the web service passing in a AddressValidationRequest and returning a AddressValidationReply
Console.WriteLine("--- Sending Request..... ---")
Dim reply As New AddressValidationReply()
reply = addressValidationService.addressValidation(request)
Console.WriteLine("--- Processing request.... ---")
''#This is where I get the error
If (Not reply.HighestSeverity = NotificationSeverityType.ERROR) And (Not reply.HighestSeverity = NotificationSeverityType.FAILURE) Then
If (Not reply.AddressResults Is Nothing) Then
For Each result As AddressValidationResult In reply.AddressResults
Console.WriteLine("Address Id - " + result.AddressId)
Console.WriteLine("--- Proposed Details ---")
If (Not result.ProposedAddressDetails Is Nothing) Then
For Each detail As ProposedAddressDetail In result.ProposedAddressDetails
Console.WriteLine("Score - " + detail.Score)
Console.WriteLine("Address - " + detail.Address.StreetLines(0))
Console.WriteLine(" " + detail.Address.StateOrProvinceCode + " " + detail.Address.PostalCode + " " + detail.Address.CountryCode)
Console.WriteLine("Changes -")
For Each change As AddressValidationChangeType In detail.Changes
Console.WriteLine(change.ToString())
Next
Console.WriteLine("")
Next
End If
Console.WriteLine("")
Next
End If
Else
For Each notification As Notification In reply.Notifications
Console.WriteLine(notification.Message)
Next
End If
Catch e As SoapException
Console.WriteLine(e.Detail.InnerText)
Catch e As Exception
Console.WriteLine(e.Message)
End Try
Console.WriteLine("Press any key to quit !")
Console.ReadKey()
End Sub
It seems to send the request object to the web service, but the"reply" object is returned with "Nothing". I could understand if I wrote the code, but good god... they can't even get their own code to work? Has anyone else seen/fixed this problem?