Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
541 views
in Technique[技术] by (71.8m points)

api - UPS XML Response 10002

I've been having some trouble getting a response from UPS' Tracking API.

I've written a VBA script that returns the following XML string and sends it to UPS' XML Tracking testing server (https://wwwcie.ups.com/ups.app/xml/Track). The tracking number is a testing one.

<?xml version="1.0"?><AccessRequest xml:lang="en-US"><AccessLicenseNumber>* MY KEY *</AccessLicenseNumber><UserId>* MY LOGIN *</UserId><Password>* MY PASSWORD *</Password></AccessRequest><?xml version="1.0"?><TrackRequest xml:lang="en-US"><Request><TransactionReference><CustomerContext>Test Case Summary Description</CustomerContext><ToolVersion>1.0</ToolVersion></TransactionReference><RequestAction>Track</RequestAction><RequestOption>1</RequestOption></Request><TrackingNumber>1Z12345E0291980793</TrackingNumber></TrackRequest>

I've formatted it here for ease of reading:

<?xml version="1.0"?>
<AccessRequest xml:lang="en-US">
    <AccessLicenseNumber>* MY KEY *</AccessLicenseNumber>
    <UserId>* MY LOGIN *</UserId>
    <Password>* MY PASSWORD *</Password>
</AccessRequest>
<?xml version="1.0"?>
<TrackRequest xml:lang="en-US">
    <Request>
        <TransactionReference>
            <CustomerContext>Test Case Summary Description</CustomerContext>
            <ToolVersion>1.0</ToolVersion>
        </TransactionReference>
        <RequestAction>Track</RequestAction>
        <RequestOption>1</RequestOption>
    </Request>
    <TrackingNumber>1Z12345E0291980793</TrackingNumber>
</TrackRequest>

This is actually a derivative of an example XML that they give in the developer's guide, yet it consistently returns the following error:

<?xml version="1.0"?>
<TrackResponse>
  <Response>
    <ResponseStatusCode>0</ResponseStatusCode>
    <ResponseStatusDescription>Failure</ResponseStatusDescription>
    <Error>
      <ErrorSeverity>Hard</ErrorSeverity>
      <ErrorCode>10002</ErrorCode>
      <ErrorDescription>The XML document is well formed but the document is not valid</ErrorDescription>
    </Error>
  </Response>
</TrackResponse>

I've seen this posted several times and and most people are missing something small or a silly error but I've been over this several times and tried many different derivatives, it has yet to return a correct response. I have been through the developer's guide and double checked that all required requests are present and correct. I'm hoping that someone can point out my error because I've started going in circles.

Many thanks in advance!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The error description says it all. You need to validate your XML submission against an XSD provided by UPS before any submission to UPS.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...