Hello forums!!
I am using Amazon's seller central SOAP API for posting documents (inventory uploads, price updates, stock updates etc.) with PHP5 as platform.
I am using PEAR::SOAP library for consuming SOAP services(As PEAR::SOAP supports MIME attachments while PHP5 SOAP extension doesn't).
After many trials and struggle I got succeed on uploading the XML feeds(for stock updates).But when i tried to check the inventory upload error log(with the TransactionID returned during upload) i got an error.
Code Details
XML Feed(stock.xml):
Code XML:<?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>your_seller_central_merchant_id</MerchantIdentifier> </Header> <MessageType>Inventory</MessageType> <Message> <MessageID>1</MessageID> <OperationType>Update</OperationType> <Inventory> <SKU>PRODUCT_SKU_123</SKU> <Quantity>10</Quantity> </Inventory> </Message> </AmazonEnvelope>
PHP Code used for posting document:
Code PHP:<?php ################################################################ # Using PEAR::SOAP - Start ################################################################ require_once('SOAP/Client.php'); require_once("SOAP/Value.php"); $proxy = array('user' => 'your_seller_central_email', 'pass' => 'your_seller_central_pass'); $merchant = array('merchantIdentifier' => 'your_seller_central_merchant_id', 'merchantName' => 'your_seller_central_merchant_name'); $client = new SOAP_Client('https://merchant-api.amazon.co.uk/gateway/merchant-interface-mime', true, false, $proxy); $doc = new SOAP_Attachment('doc', 'text/xml', dirname(__FILE__) .'/stock.xml'); $method = 'postDocument'; $messageType = '_POST_INVENTORY_AVAILABILITY_DATA_'; $params = array('merchant' => $merchant, 'messageType' => $messageType, 'doc' => $doc); $options = array('attachments'=>'Mime'); $response = $client->call($method, $params, $options); if(PEAR::isError($response)){ echo 'Code::'.$response->getCode().'<br />Error::'.$response->getMessage(); }else{ print_r($response); } ################################################################ # Using PEAR::SOAP - End ################################################################ ?>
ERROR returned while checking for inventory upload error log:
Code XML:<?xml version="1.0"?> <AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd"> <Header> <DocumentVersion>1.02</DocumentVersion> <MerchantIdentifier>your_seller_central_merchant_id</MerchantIdentifier> </Header> <MessageType>ProcessingReport</MessageType> <Message> <MessageID>1</MessageID> <ProcessingReport> <DocumentTransactionID>XXXXXXX</DocumentTransactionID> <StatusCode>Complete</StatusCode> <ProcessingSummary> <MessagesProcessed>0</MessagesProcessed> <MessagesSuccessful>0</MessagesSuccessful> <MessagesWithError>0</MessagesWithError> <MessagesWithWarning>0</MessagesWithWarning> </ProcessingSummary> <Result> <MessageID>0</MessageID> <ResultCode>Error</ResultCode> <ResultMessageCode>5000</ResultMessageCode> <ResultDescription>Line Number: 1 Column Number: 1 Error Message: Invalid document structure</ResultDescription> </Result> </ProcessingReport> </Message> </AmazonEnvelope>
Note: Previoulsy I tried with AIM API but couldn't succeed which only returned 'Invalid Input' error.
Later I came to know that AIM doesn't work for posting documents for seller central accounts,
and Seller Central SOAP API works good for posting documents(sample code of C# and JAVA has also been mentioned in the seller central help section).
I have Seller Central Account for UK.
I browsed the amazon forums and came to know that nobody has accomplished the task of posting documents successfully with PHP either using AIM and SOAP. Though fetching documents from Amazon works great with both APIs.
Finally::Can anybody can point out the error in my process/code?
Thanks in advance for the valueable tips/suggestions.
Thanks
Best Regards
PHPycho






si="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd"> <Header> <DocumentVersion>1.01</DocumentVersion> <MerchantIdentifier>your_seller_central_merchant_id</MerchantIdentifier> </Header> <MessageType>Inventory</MessageType> <Message> <MessageID>1</MessageID> <OperationType>Update</OperationType> <Inventory> <SKU>PRODUCT_SKU_123</SKU> <Quantity>10</Quantity> </Inventory> </Message></AmazonEnvelope>
Bookmarks