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

孤者浪人 提交于 2019-12-05 21:41:49
Hazzit

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:

  1. 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)
  2. Change both opening and closing tags to OrderAcknowledgement (same as above)
  3. 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>

You say "I have checked my data against the XSD files and the XML seems valid ", but neither of the schema documents you mention has declarations for your outermost element (nor for some others, but I won't bother with a list). And what Amazon is telling you is that the XML is not, in fact, valid.

Your task, then, is to use an XSD validator to figure out what is invalid in the document you are submitting. To make that work, you will need to point the validator to the schema documents being used by the Amazon validator, or a copy of them -- if the validator you are using cannot find all of the necessary declarations (as its error message explains), then it's unlikely to be helpful to you.

For what it's worth, I tried to validate your data using the schema document cited by the documentation you mention (https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/xsd/release_1_9/amzn-envelope.xsd), but the documents Amazon.xsd and MaterialHandling.xsd (included in their turn by Product.xsd) do not appear to be where the relative references suggest they should. So more homework may be needed to put together a working schema from the Amazon schema documents than one might have expected.

As far as I can tell, the immediate problems with your XML document are:

  • The content of MessageType is spelled "OrderAcknowledgment" instead of "OrderAcknowledgement".
  • The element following MessageType is named OrderAcknowledgment; I guess you mean OrderAcknowledgement.
  • Your Item element has multiple order item codes instead of just one; I think you mean something like

    <Item>
      <AmazonOrderItemCode>35287489587654</AmazonOrderItemCode>
      <MerchantOrderItemID>587487</MerchantOrderItemID>
    </Item>
    <Item>
      <AmazonOrderItemCode>35287489587655</AmazonOrderItemCode>
      <MerchantOrderItemID>587488</MerchantOrderItemID>
    </Item>
    

Good luck.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!