Amazon MWS order acknowledgement returning error 25: We are unable to process the XML feed because one or more items are invalid

amazon-mws, xml, xsd

Solution

I'm currently trying to get a hold of all necessary XSDs to actually validate MWS files, but with little luck so far. Most validators will choke if a single XSD is missing, even if its contents are not relevant to the file it is currently validating. Amazon sure does make it hard to actually validate stuff- unless I'm missing something obvious.

My interim solution is to use a "crippled" XSD that only links to other XSDs that I actually have a copy of. Using this file is not perfect, but better than nothing. The way these XSDs are nested, anything I can validate with my XSD is actually valid. The only downside is that valid XMLs exist that I cannot validate, that I have to live with.

Using this set of XSDs, I had to make the following changes to your XML in order to pass validation:

- Change the MessageType to OrderAcknowledgement (extra "e" after the g. whether you like that spelling may depend on which side of the pond you live, nevertheless the XSD commands that exact spelling)

- Change both opening and closing tags to OrderAcknowledgement (same as above)

- Splitting that one Item into two (the StackOverflow question you linked has it wrong)

(I started writing this answer under the impression of C. M. Serperg-McQueen getting the spelling mixed up... I just read it again, and as it turns out, he was spot on, and I'm should improve my reading skills)

The validator message regarding AmazonOrderID was misleading. It was most probably a result of that validator also missing parts of the XSD.

Just for the sake of completeness. This file passed the (crippled) validation:

<?xml version="1.0"?>
<AmazonEnvelope 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
  <Header>
    <DocumentVersion>1.01</DocumentVersion>
    <MerchantIdentifier>F85S4E7G4FSE98</MerchantIdentifier>
   </Header>
   <MessageType>OrderAcknowledgement</MessageType>
   <Message>
    <MessageID>1</MessageID>
    <OrderAcknowledgement>
      <AmazonOrderID>654-8547853-2598634</AmazonOrderID>
      <MerchantOrderID>658795124</MerchantOrderID>
      <StatusCode>Success</StatusCode>
      <Item>
        <AmazonOrderItemCode>35287489587654</AmazonOrderItemCode>
        <MerchantOrderItemID>587487</MerchantOrderItemID>
      </Item>
      <Item>
        <AmazonOrderItemCode>35287489587655</AmazonOrderItemCode>
        <MerchantOrderItemID>587488</MerchantOrderItemID>
      </Item>
    </OrderAcknowledgement>
  </Message>
</AmazonEnvelope>

Problem

I am having some trouble submitting an order acknowledgement to Amazon via the Amazon MWS. The XML I am submitting is: ``` <?xml version="1.0"?> <AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd"> <Header> <DocumentVersion>1.01</DocumentVersion> <MerchantIdentifier>F85S4E7G4FSE98</MerchantIdentifier> </Header> <MessageType>OrderAcknowledgment</MessageType> <Message> <MessageID>1</MessageID> <OrderAcknowledgment> <AmazonOrderID>654-8547853-2598634</AmazonOrderID> <MerchantOrderID>658795124</MerchantOrderID> <StatusCode>Success</StatusCode> <Item> <AmazonOrderItemCode>35287489587654</AmazonOrderItemCode> <MerchantOrderItemID>587487</MerchantOrderItemID> <AmazonOrderItemCode>35287489587655</AmazonOrderItemCode> <MerchantOrderItemID>587488</MerchantOrderItemID> </Item> </OrderAcknowledgment> </Message> </AmazonEnvelope> ``` On submitting the XML the error returned by Amazon is: Error 25: We are unable to process the XML feed because one or more items are invalid. Please re-submit the feed. I have created the XML by following the Guide to XML documentation supplied by Amazon. Based on this Stack Overflow question the format for multiple items is correct. I have checked my data against the XSD files and the XML seems valid https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/xsd/release_1_9/OrderAcknowledgement.xsd https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/xsd/release_1_9/amzn-base.xsd I have tried using an XML XSD validator to validate the XML, but it returns the error: Src-resolve: Cannot Resolve The Name 'AmazonOrderID' To A(n) 'element Declaration' Component. This error does not make much sense to me, but I believe it is being returned due to numerous inclusions of other XSC that I cannot properly reference in the validator. The restrictions for the 'AmazonOrderID' are located in the amzn-base.xsd file and match the AmazonOrderID I have provided ``` <xsd:element name="AmazonOrderID"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:pattern value="\w{3}-\w{7}-\w{7}"/> </xsd:restriction> </xsd:simpleType> </xsd:element> ``` I have tried acknowledging a single item in the order incase the structure for multiple items is incorrect I have tried removing the items section completely as I read the items section is sometimes not needed I have tried submitting via a php script I have created which handles all other request successfully I have tried submitting via the Amazon scratchpad: https://mws.amazonservices.co.uk/scratchpad/index.html Nothing I have tried has resolved the issue and I am all out of ideas Any help you could provide would be greatly appreciated Thank you

Original source