gpt4 book ai didi

c# - UPS 地址街道级别验证

转载 作者:行者123 更新时间:2023-12-02 15:16:33 28 4
gpt4 key购买 nike

这可能是一个非常普遍的问题,但有人很幸运地使用了 UPS 街道级验证 API 吗?我研究了其中的部分内容:http://www.codeproject.com/KB/aspnet/Benz_CPE.aspx?msg=3658759&display=Mobile

还有这个: https://www.ups.com/upsdeveloperkit/downloadresource?loc=en_US

UPS 对他们自己的示例代码没有太大帮助。即使在获得访问 key 后,他们的样本仍坚持提供的状态无效的样本数据(即使具有测试环境可接受的状态)。寻找更多线索。

最佳答案

UPS 通知我,C# 示例配置为“城市化”,仅适用于波多黎各。我修改了代码如下:

class XAVWSClient
{
static void Main()
{
try
{
XAVService xavSvc = new XAVService();
XAVRequest xavRequest = new XAVRequest();
UPSSecurity upss = new UPSSecurity();
UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSSecurityServiceAccessToken();
upssSvcAccessToken.AccessLicenseNumber = ;
upss.ServiceAccessToken = upssSvcAccessToken;
UPSSecurityUsernameToken upssUsrNameToken = new UPSSecurityUsernameToken();
upssUsrNameToken.Username = ;
upssUsrNameToken.Password = ;
upss.UsernameToken = upssUsrNameToken;
xavSvc.UPSSecurityValue = upss;
RequestType request = new RequestType();

//Below code contains dummy data for reference. Please update as required.
String[] requestOption = { "1" };
request.RequestOption = requestOption;
xavRequest.Request = request;
AddressKeyFormatType addressKeyFormat = new AddressKeyFormatType();
String[] addressLine = { "3930 KRISTI COURT" };
addressKeyFormat.AddressLine = addressLine;
addressKeyFormat.PoliticalDivision2 = "SACRAMENTO";
addressKeyFormat.PoliticalDivision1 = "CA";
addressKeyFormat.PostcodePrimaryLow = "95827";
addressKeyFormat.ConsigneeName = "Some Consignee";
addressKeyFormat.CountryCode = "US";
xavRequest.AddressKeyFormat = addressKeyFormat;
System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();

//serialize object (Debugging)
System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(xavRequest.GetType());
Stream stream = File.Open("SerializedXAVRequest.xml", FileMode.Create);
x.Serialize(stream, xavRequest);

XAVResponse xavResponse = xavSvc.ProcessXAV(xavRequest);

Console.WriteLine("Response Status Code " + xavResponse.Response.ResponseStatus.Code);
Console.WriteLine("Response Status Description " + xavResponse.Response.ResponseStatus.Description);
Console.ReadLine();

虽然我现在可以验证我的凭据,但我无法生成多个结果,而且我不确定它是否正在进行任何验证,因为即使我输入了虚假地址,我也会收到以下内容:

响应状态代码 1响应状态描述成功

当我的问题达到这一点时,我会发布另一个问题。到那时,这个问题就有了答案。

关于c# - UPS 地址街道级别验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8481442/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com