在验证地址时,我收到以下错误:
ex = {"Error Loading XML: The following tags were not closed: AddressValidateRequest, Address, Address1.\r\n"}或者我得到另一个错误,说地址找不到。有没有更好的方法来验证这个地址?
这是我的URL:
http://production.shippingapis.com/ShippingAPI.dll?API=Verify&XML=<AddressValidateRequest USERID="402JMAWE3481"><Address ID="1"><Address1>123 Main St</Address1><Address2></Address2><City>Watertown</City><State>MA</State><Zip5>02472</Zip5><Zip4></Zip4></Address></AddressValidateRequest>发布于 2012-08-07 19:53:19
实际上,您需要先HtmlEncode它,然后再UrlEncode它。这是因为您实际上发送的是XML (需要&而不是&),但它是一个URL,因此需要对每个&进行编码以将其转换为%26
这是一个完整的工作URL --你只需要输入你的用户in。
http://production.shippingapis.com/ShippingAPI.dll?API=Verify&XML=<AddressValidateRequest USERID="123USERID567"><Address ID="1"><Address1></Address1><Address2>10051+Orr+%26amp%3b+Day+Rd</Address2><City>santa+fe+springs</City><State>ca</State><Zip5>90670</Zip5><Zip4></Zip4></Address></AddressValidateRequest>你会看到它包含这个看起来很时髦的字符串:
10051+Orr+%26amp%3b+Day+Rd我通过这样做得到的:
HttpUtility.UrlEncode(HttpUtility.HtmlEncode("10061 Orr & Day Rd"))当我没有正确编码时,我得到的这个特定错误是Error Loading XML: Whitespace is not allowed at this location
https://stackoverflow.com/questions/10955988
复制相似问题