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,
<accessReques t> and <addressValidat ionRequest>.
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 <accessReques t> 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"?>
<accessReques t>
<accessLicenseN umber>123abcmya ccesscode</AccessLicenseNu mber>
<UserId>xxxxx x</UserId>
<Password>yyyyy y</Password>
</AccessRequest>
<?xml version="1.0" encoding="UTF-8"?>
<addressValidat ionRequest xml:lang="en-US">
<Request>
<TransactionRef erence>
<CustomerContex t>Mr UPS</CustomerContext >
<XpciVersion>1. 0001</XpciVersion>
</TransactionRefe rence>
<RequestAction> AV</RequestAction>
</Request><addres s><City>Pottsvi lle</City>
<StateProvinceC ode>PA</StateProvinceCo de>
</Address>
</AddressValidati onRequest>
=============== =============== =============== =============== ==
========== Exhibit 2 my code snippet =============== =============== ===============
=============== =============== =============== =============== =======
Exhibit 3: (modified the UPS XML to have 1 top level element)
<?xml version="1.0" encoding="UTF-8"?>
<accessReques t>
<accessLicenseN umber>123abcmya ccesscode</AccessLicenseNu mber>
<UserId>xxxxx x</UserId>
<Password>yyyyy y</Password>
<addressValidat ionRequest xml:lang="en-US">
<Request>
<TransactionRef erence>
<CustomerContex t>Mr UPS</CustomerContext >
<XpciVersion>1. 0001</XpciVersion>
</TransactionRefe rence>
<RequestAction> AV</RequestAction>
</Request><addres s><City>Pottsvi lle</City>
<StateProvinceC ode>PA</StateProvinceCo de>
</Address>
</AddressValidati onRequest>
</AccessRequest>
=============== =============== =============== =============== ==
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,
<accessReques t> and <addressValidat ionRequest>.
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 <accessReques t> 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"?>
<accessReques t>
<accessLicenseN umber>123abcmya ccesscode</AccessLicenseNu mber>
<UserId>xxxxx x</UserId>
<Password>yyyyy y</Password>
</AccessRequest>
<?xml version="1.0" encoding="UTF-8"?>
<addressValidat ionRequest xml:lang="en-US">
<Request>
<TransactionRef erence>
<CustomerContex t>Mr UPS</CustomerContext >
<XpciVersion>1. 0001</XpciVersion>
</TransactionRefe rence>
<RequestAction> AV</RequestAction>
</Request><addres s><City>Pottsvi lle</City>
<StateProvinceC ode>PA</StateProvinceCo de>
</Address>
</AddressValidati onRequest>
=============== =============== =============== =============== ==
========== Exhibit 2 my code snippet =============== =============== ===============
Code:
Set myHTTP = CreateObject("msxml2.xmlhttp")
Set myDom = CreateObject("MSXML2.DOMDocument")
myDom.async = False
If myDom.loadXML(MYxml) = False Then
MsgBox "MYxml failed to load" ' THIS MESSAGE IS BEING DISPLAYED
End If
myDom.loadXML (MYxml) ' load my xml code
myHTTP.Open "POST", strUPSWebAddressTest, False
myHTTP.setRequestHeader "Content-Type", "multipart/form-data; boundary=" & strBoundary
myHTTP.setRequestHeader "Content-Disposition", "form-data; name=""xmlmsg"""
myHTTP.setRequestHeader "Content-Length", Len(MYxml)
MsgBox myDom.XML
myHTTP.Send (myDom.XML)
MsgBox myHTTP.responseText
MYResponse = myHTTP.responseText
Exhibit 3: (modified the UPS XML to have 1 top level element)
<?xml version="1.0" encoding="UTF-8"?>
<accessReques t>
<accessLicenseN umber>123abcmya ccesscode</AccessLicenseNu mber>
<UserId>xxxxx x</UserId>
<Password>yyyyy y</Password>
<addressValidat ionRequest xml:lang="en-US">
<Request>
<TransactionRef erence>
<CustomerContex t>Mr UPS</CustomerContext >
<XpciVersion>1. 0001</XpciVersion>
</TransactionRefe rence>
<RequestAction> AV</RequestAction>
</Request><addres s><City>Pottsvi lle</City>
<StateProvinceC ode>PA</StateProvinceCo de>
</Address>
</AddressValidati onRequest>
</AccessRequest>
=============== =============== =============== =============== ==
Comment