代码之家  ›  专栏  ›  技术社区  ›  Pievis

分析xml时,Amazon Marketplace API ProductImage Feed出现意外元素错误

  •  0
  • Pievis  · 技术社区  · 10 年前

    我正在使用java中的amazon mws提要api,在向amazon发送ProductImage提要时遇到了一些问题。

    这是我要发送的xml:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <ProductImage>
        <SKU>ABCDORD0001</SKU>
        <ImageType>Main</ImageType>
        <ImageLocation>http://vocearancio.ingdirect.it/wp-content/uploads/2013/01/bici-1.jpeg</ImageLocation>
    </ProductImage>
    

    这是web服务响应(只是有趣的部分):

                <Result>
                    <MessageID>1</MessageID>
                    <ResultCode>Error</ResultCode>
                    <ResultMessageCode>5000</ResultMessageCode>
                    <ResultDescription>XML Parsing Error at Line 2, Column 15: Found unexpected element &apos;ProductImage&apos; while parsing the start of this &apos;AmazonEnvelope&apos; document. Children of this element will be ignored by the parser..</ResultDescription>
                </Result>
    

    我不明白他为什么忽略ProductImage标记,我在文档中引用了一个示例,应该没问题。 我正在发送提要 request.setFeedType("_POST_PRODUCT_IMAGE_DATA_"); 是因为我缺少信封部分吗?我认为java API做到了这一点,我对其他提要没有问题(即使产品在销售中心库存中没有显示)。

    这是我的POST_PRODUCT_DATA提要(我应该发送的第一个提要,而不是上面的提要),返回时没有错误:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Product>
        <SKU>ABCDORD0001</SKU>
        <LaunchDate>2014-11-10T00:00:00.000+01:00</LaunchDate>
        <ReleaseDate>2014-11-10T00:00:00.000+01:00</ReleaseDate>
        <Condition>
            <ConditionType>New</ConditionType>
        </Condition>
        <DescriptionData>
            <Title>titolo_articolo</Title>
            <Brand>brand_item</Brand>
            <Description>descrizione_articolo_dett</Description>
            <ItemType>sotto_categoria</ItemType>
        </DescriptionData>
        <ProductData>
            <Sports></Sports>
        </ProductData>
    </Product>
    

    我希望有人能帮忙。

    2 回复  |  直到 10 年前
        1
  •  0
  •   Community paulsm4    7 年前

    这听起来像是在使用 _POST_PRODUCT_DATA_ 提交饲料消耗。

    相反,您需要使用 _POST_PRODUCT_IMAGE_DATA_ 常数有关于 workflow here 。看看 Selling on Amazon, Guide to XML 有关提要所需内容的详细信息。它在第47/48页提供了一个示例提要。

        2
  •  0
  •   Pievis    10 年前

    问题是我缺少了amazon信封部分,下面是我现在发送给web服务的正确xml示例:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <AmazonEnvelope>
        <Header>
            <DocumentVersion>1.01</DocumentVersion>
            <MerchantIdentifier>A2UAUVMGTII0KR</MerchantIdentifier>
        </Header>
        <MessageType>Product</MessageType>
        <Message>
            <MessageID>1</MessageID>
            <OperationType>Update</OperationType>
            <Product>
                <SKU>ABCDORD0005</SKU>
                <StandardProductID>
                    <Type>ISBN</Type>
                    <Value>9788478888566</Value>
                </StandardProductID>
                <LaunchDate>2014-03-23T00:00:00.000+01:00</LaunchDate>
                <ReleaseDate>2014-03-23T00:00:00.000+01:00</ReleaseDate>
                <Condition>
                    <ConditionType>New</ConditionType>
                </Condition>
                <DescriptionData>
                    <Title>Harry Potter and the Philosopher's Stone</Title>
                    <Brand>brand_item</Brand>
                    <Description>Harry Potter and the Philosopher's Stone is the first novel in the Harry Potter series, written by J. K. Rowling.</Description>
                    <Manufacturer>J. K. Rowling</Manufacturer>
                    <ItemType>sotto_categoria</ItemType>
                </DescriptionData>
                <ProductData>
                    <Sports></Sports>
                </ProductData>
            </Product>
        </Message>
    </AmazonEnvelope>
    

    这项工作很好,没有返回错误,只需注意,产品在卖家中心购物大约需要1分钟,处理和激活需要10分钟。 此外,StandardProductID元素非常重要,如果你没有提供正确的代码,你会得到一个缺少键的错误。