473,320 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

UPS Address Validation with XML

1,271 Expert 1GB
I'm feeling like the 7th blind guy, the one feeling his way around the pile behind the elephant. I think what I am trying to do is very simple, but it's not turning out like that.

I'm trying to do real-time UPS address validation via XML. I have zero knowledge of and experience with XML. I've studied the developer's guide from UPS and created some code to produce a simple string of text that looks like this Exibit 1 below. UPS insists it must be like that. However it doesn't come close to working.

I'm working in Access/VBA. Exhibit 2 is a snippet of the code. The problem I'm having is that when I produce the XML UPS says to use, the loadXML command returns a "False" result. Which means I have no XML loaded, so the subsequent .Send is useless.

I've even put their code into a .xml file and tried to open it with a browser and it
complains that "Only one top level element is allowed in an XML document". Which actually made me feel good, because I thought that was something I understood about XML and the error made sense to me. It seems to me the UPS code has two top level elements,
<accessRequest> and <addressValidationRequest>.

When I move the </AccessRequest> to the bottom of the file, (exhibit 3) the browser is happy and displays the content. I suppose like that <accessRequest> is the only top level element. When I change my code to produce this XML, the .loadXML command works okay, but UPS chokes on it and send an Error response about badly formatted XML. I also took the UPS code and wrapped it in a made up element, <doc> </doc> so there was only 1 top level element. That made the .loadXML statement happy but UPS still sent back an error "Missing XML declaration in the XML document".

After 3 days I've pretty much given up on UPS tech support giving any real support. They eventually moved me up a level, and that guy just spit back the same code I already had, only he added the " encoding="UTF-8"" part of the code. And he reminded me I really should read the developers' manual and just do what it says.

I can't believe they are actually wrong about what their xml request should look like. Somehow we're not communicating something important. They're assuming something about my environment or something and I don't know enough to ask the right questions.

I'm developing this in Access 2003 and I've got a reference to MSXML v6.0.

Any suggestions or nuggets of wisdom would be greatly appreciated.

Thanks,
Jim Wolf


================================================== ==========
Exhibit 1: UPS' XML file
<?xml version="1.0" encoding="UTF-8"?>
<accessRequest>
<accessLicenseNumber>123abcmyaccesscode</AccessLicenseNumber>
<UserId>xxxxxx</UserId>
<Password>yyyyyy</Password>
</AccessRequest>
<?xml version="1.0" encoding="UTF-8"?>
<addressValidationRequest xml:lang="en-US">
<Request>
<TransactionReference>
<CustomerContext>Mr UPS</CustomerContext>
<XpciVersion>1.0001</XpciVersion>
</TransactionReference>
<RequestAction>AV</RequestAction>
</Request><address><City>Pottsville</City>
<StateProvinceCode>PA</StateProvinceCode>
</Address>
</AddressValidationRequest>
================================================== ============

========== Exhibit 2 my code snippet =============================================
Expand|Select|Wrap|Line Numbers
  1. Set myHTTP = CreateObject("msxml2.xmlhttp")
  2. Set myDom = CreateObject("MSXML2.DOMDocument")
  3. myDom.async = False
  4. If myDom.loadXML(MYxml) = False Then
  5.     MsgBox "MYxml failed to load"  ' THIS MESSAGE IS BEING DISPLAYED
  6. End If
  7.  
  8. myDom.loadXML (MYxml)  ' load my xml code
  9.  
  10. myHTTP.Open "POST", strUPSWebAddressTest, False
  11. myHTTP.setRequestHeader "Content-Type", "multipart/form-data; boundary=" & strBoundary
  12. myHTTP.setRequestHeader "Content-Disposition", "form-data; name=""xmlmsg"""
  13. myHTTP.setRequestHeader "Content-Length", Len(MYxml)
  14. MsgBox myDom.XML
  15. myHTTP.Send (myDom.XML)
  16. MsgBox myHTTP.responseText
  17. MYResponse = myHTTP.responseText
  18.  
================================================== =================
Exhibit 3: (modified the UPS XML to have 1 top level element)
<?xml version="1.0" encoding="UTF-8"?>
<accessRequest>
<accessLicenseNumber>123abcmyaccesscode</AccessLicenseNumber>
<UserId>xxxxxx</UserId>
<Password>yyyyyy</Password>
<addressValidationRequest xml:lang="en-US">
<Request>
<TransactionReference>
<CustomerContext>Mr UPS</CustomerContext>
<XpciVersion>1.0001</XpciVersion>
</TransactionReference>
<RequestAction>AV</RequestAction>
</Request><address><City>Pottsville</City>
<StateProvinceCode>PA</StateProvinceCode>
</Address>
</AddressValidationRequest>
</AccessRequest>
================================================== ============
May 1 '10 #1
1 5792
jimatqsi
1,271 Expert 1GB
Okay, I figured it out finally. I changed
myHTTP.Send (myDom.XML)
to
myHTTP.Send (myXML)

Apparently UPS just wants the string of XML command text (even though it is does not really equal a valid XML file). The DOMDocument insists on valid XML XML so it won't even load the improperly formatted UPS command set.

Please chime in if you can add anything helpful about this.

Jim
May 3 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Alan Zhong | last post by:
when designing the address data entry webpage, i wonder... is there an online map/direction webpage that allow us to check if an address is validate? or auto-completes city names from the zip code?
25
by: Dynamo | last post by:
Hi The following script was taken from John Coggeshall's (PHP consultant) in his article on Zends site at http://www.zend.com/zend/spotlight/ev12apr.php // Get the email address to validate...
35
by: Mika M | last post by:
Simple question: Does Framework (1.1) contain any routine to check entered email-address is valid ? It's quite easy to make own code for that purpose, but why to do if Framework (1.1) contain...
4
by: somaskarthic | last post by:
Hi Can anyone send javascript code to validate the network mac address(eg. 02:41:6d:22:12:f1) It accepts value from 00:00:00:00:00:00 to ff:ff:ff:ff:ff:ff. On keypress event of textbox , i...
0
by: Fur Data | last post by:
Hello, We are developing and providing the virtual market with an address validation add-on for 18 countries. A realtime prototype website can be visit at www.address-validation.com Via a...
5
by: wizard04 | last post by:
I'm trying to validate an email address field before it is submitted. I have read RFC 822 (http://www.faqs.org/rfcs/rfc822.html) but I'm not sure I'm fully grasping it. As far as I understand, a...
8
by: cfmx2008 | last post by:
Hi All, I'm creating a form that it will parse a valid address in the address1 field from an address library to make sure this is a valid address. Here is the problem: The address is followed by...
4
by: JvC | last post by:
Does anyone have a good routine for EMail address validation? The one that I use is fairly primitive, and I need to beef it up. I have downloaded several from the web, and they all get screwed up...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.