7

Hello I am creating a wordpress website for a client using WooCommerce. The site is complete but the client wants the ability to create shipments from the shop_order page. I have most of this figured out, the problem is my XML request to the UPS API. I have checked and recheck, and I cant seem to find the error:

<ShipmentConfirmResponse><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></ShipmentConfirmResponse>

Below is my xml mark up with sensitive info hidden.

<?xml version="1.0" ?>
<AccessRequest xml:lang='en-US'>
    <AccessLicenseNumber>******</AccessLicenseNumber>
    <UserId>********</UserId>
    <Password>********</Password>
</AccessRequest>
    <?xml version="1.0" ?>
    <ShipConfirmRequest xml:lang='en-US'>
    <Request>
    <TransactionReference>
        <CustomerContext>Customer Context</CustomerContext>
        <XpciVersion>1.0</XpciVersion>
    </TransactionReference>
     <RequestAction>ShipConfirm</RequestAction>
     <RequestOption>validate</RequestOption>
 </Request>
 <Shipment>
     <Shipper>
        <ShipperNumber>*******</ShipperNumber>
         <Name>Canyon Werks, LLC</Name>
         <Address>
             <AddressLine>2941 Brookspark Drive</AddressLine>
            <AddressLine></AddressLine>
            <City>North Las Vegas</City>
            <StateProvinceCode>NV</StateProvinceCode>
            <PostalCode>89030</PostalCode>
            <CountryCode>US</CountryCode>
        </Address>
        <Phone>
            <Number>7022552222</Number>
        </Phone>
    </Shipper>
    <ShipTo>
        <Name>Justin Walker</Name>
        <Address>
            <AddressLine>2675 Windmill Pkwy</AddressLine>
            <AddressLine>3024</AddressLine>
            <City>Henderson</City>
            <StateProvinceCode>NV</StateProvinceCode>
            <PostalCode>89074</PostalCode>
            <CountryCode>US</CountryCode>
        </Address>
        <Phone>
            <Number>7024609485</Number>
        </Phone>
    </ShipTo>
    <ShipFrom>
        <Name>Canyon Werks, LLC</Name>
        <Address>
            <AddressLine>2941 Brookspark Drive</AddressLine>
            <AddressLine></AddressLine>
            <City>North Las Vegas</City>
            <StateProvinceCode>NV</StateProvinceCode>
            <PostalCode>89030</PostalCode>
            <CountryCode>US</CountryCode>
        </Address>
        <Phone>
            <Number>7022552222</Number>
        </Phone>
    </ShipFrom>
    <PaymentInformation>
        <ShipmentCharge>
            <Type>01</Type>
            <BillShipper>
                <AccountNumber>*******</AccountNumber>
            </BillShipper>
        </ShipmentCharge>
    </PaymentInformation>
    <Service>
        <Code>03</Code>
    </Service>
    <Package>
        <Packaging>
            <Code>02</Code>
            <Description>Customer Supplied</Description>
        </Packaging>
        <Dimensions>
            <UnitOfMeasurement>
                <Code>IN</Code>
            </UnitOfMeasurement>
            <Length>16</Length>
            <Width>12</Width>
            <Height>6</Height>
        </Dimensions>
        <PackageWeight>
            <UnitOfMeasurement>
                <Code>LBS</Code>
            </UnitOfMeasurement>
            <Weight>6.07</Weight>
        </PackageWeight>
    </Package>
</Shipment>
<LabelSpecification>
    <LabelImageFormat>
        <Code>GIF</Code>
    </LabelImageFormat>
</LabelSpecification>
</ShipConfirmRequest>

I am almost there on this, but I am stuck at this road block. If anyone can shed some light into this it would be much appreciated.

Tim Burch
  • 1,088
  • 7
  • 9
Jusmark123
  • 213
  • 1
  • 3
  • 11
  • 3
    Your example is two xml documents - not one. Two ` ` - This is not valid. – ThW Nov 29 '13 at 22:30
  • Has anyone found solution to this ? – Ani Jul 16 '14 at 20:45
  • as strange as this looks, it is UPS standard. [sigh] Take it as an omen for further surprises.. They must do some type of pre-processing first. – Mustapha George Jul 27 '14 at 21:41
  • @MustaphaGeorge: Can you provide reference for that? I tried to dig this bare request format up from their docs but haven't found it so far. Would be good to give this some grounds in specs. – hakre Jul 30 '14 at 13:53

2 Answers2

4

It was the service code container it must be included in the package container. I had it before it. Took me quite a while to figure out this dumb mistake on my part.

Before:

...
<Service>
    <Code>03</Code>
</Service>
<Package>
    ...

After:

...
<Package>
    <Service>
        <Code>03</Code>
    </Service>
    ...

Thanks for the help, and yes UPS requires a strange XML format.

hakre
  • 193,403
  • 52
  • 435
  • 836
Jusmark123
  • 213
  • 1
  • 3
  • 11
-3

The XML processing instruction appears twice:

<?xml version="1.0" ?>

This indicates the presence of two distinct XML documnents:

<?xml version="1.0" ?>
<AccessRequest xml:lang='en-US'>
  <AccessLicenseNumber>******</AccessLicenseNumber>
  <UserId>********</UserId>
  <Password>********</Password>
</AccessRequest>

and

<?xml version="1.0" ?>
<ShipConfirmRequest xml:lang='en-US'>
  <Request>
    <TransactionReference>
      <CustomerContext>Customer Context</CustomerContext>
      <XpciVersion>1.0</XpciVersion>
    </TransactionReference>
    <RequestAction>ShipConfirm</RequestAction>
    <RequestOption>validate</RequestOption>
  </Request>
  <!-- ... -->
</ShipConfirmRequest>
DavidRR
  • 18,291
  • 25
  • 109
  • 191
  • 6
    While this answer would be right in just about any other context, it is incorrect in the context of the UPS shipping API. Believe it or not, the UPS API really does require requests that consist of such poorly formed XML (don't ask me why). – Tim Burch Apr 28 '14 at 13:09
  • @TimBurch i am agreed with your concern . – A.Goutam Jun 13 '14 at 07:51
  • It is weird, I know I had to issues with the format as well. I was able to get it working it was simply me trying too hard...lol. – Jusmark123 Dec 28 '14 at 09:35