Welcome Guest. Sign in or Signup

1 Answers

LMS Sample – deserialize java objects from the xml returned in downloadFile API in JAVA

Asked by: 666 views Programming


  You can use the JAXB Unmarshaller interface to inflate an XML document into a java object or to deserialize java objects from xml.   This sample illustrates the use of JAVA JAXB framework to unzip the file returned in downloadFile API 
 and unmarshal the Merchant Data xml document that based on Merchant Data Schema.

  To run this program, you will need to first generate java classes that represent the Marchant Data Schema.  Pleaes refer to the construct LMS data files with eBay Merchant Data Schema in JAVA kb for the codeGen ant script for the same.

 Also, you can check the attached Java source code for the implementation of the BulkDataExchangeResponse xml for ReviseFixedPriceItem call.

import ebay.apis.eblbasecomponents.BulkDataExchangeResponsesType;
import ebay.apis.eblbasecomponents.ExternalTransactionType;
import ebay.apis.eblbasecomponents.OrderDetailsType;
import ebay.apis.eblbasecomponents.SoldReportResponseType;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Unmarshaller;

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

public class SoldReport{

    private static String jaxb_object_tree_package_name = “ebay.apis.eblbasecomponents”;
    private static String destinationPathForUnzipped = “C:\tmp\unzipped\”;

    public static void main(String[] args) {

        String soldReportFilePath=”c:\5024432353_report.gz”;
        BulkDataExchangeResponsesType bd = (BulkDataExchangeResponsesType)readResponse(soldReportFilePath);
         SoldReportResponseType soldreport = bd.getSoldReport();

            List<OrderDetailsType> list = soldreport.getOrderDetails();
            for (OrderDetailsType details : list) {