0

验证地址时,我收到此错误:

ex = {"Error Loading XML:  The following tags were not closed: AddressValidateRequest, Address, Address1.\r\n"}

或者我收到另一个错误,说找不到地址。有没有更好的方法来验证这个地址?

这是我的网址:

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>
4

2 回答 2

3

根据我在错误描述中看到的内容,问题可能是您需要\r\n先从 xml 中删除,然后再将其添加到 url。不要忘记对它进行 url 编码。

于 2012-06-08T21:12:17.970 回答
1

你实际上需要 HtmlEncode 它然后 UrlEncode 它。这是因为您实际上是在发送 XML(需要&amp;而不是),但它是一个 URL,因此它需要编码以&使每个&%26

这是一个完整的工作 URL - 您只需输入您的 USERID。

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"))

[This specific error I got back when I didn't encode properly was Error Loading XML: Whitespace is not allowed at this location]

于 2012-08-07T11:53:19.153 回答