FedEx 地址验证 Web 服务出现问题
我正在尝试开始使用 FedEx 的地址验证服务,但在使用 FedEx 自己的演示应用程序时遇到了障碍。
这是应用程序中的代码:
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
似乎将请求对象发送到 Web 服务,但“回复”对象返回“Nothing”。如果我编写代码我可以理解,但是天哪......他们甚至无法让自己的代码工作?有其他人看到/解决了这个问题吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该应用程序显示出一些明显的迹象,表明它首先是用 C# 编写的,后来转换为 VB.Net。具体来说:
可以简化为:
。
可以用多种方式编写,但至少我希望纯 VB 程序员知道
AndAlso
而不是And
或<> 而不是
Not ... = ...
。最后:创建一个新对象并立即丢弃它。
The app shows some tell-tale signs of having been first written in C# and then converted to VB.Net later. Specifically:
Could be shortened to simply:
.
could be written several ways, but at very least I would expect a pure-VB programmer to know of either
AndAlso
instead ofAnd
or<>
instead ofNot ... = ...
. Finally:creates a new object and promptly discards it.