简体   繁体   中英

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

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

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 CM 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM