Tutorial 03 - Getting a list of Landing Report Summaries

Getting a list of Landing Report Summaries

See ElandingsClient3.zip for the completed code example

Often elandings projects and third-party developers want a list of landing report summaries. A summary is much smaller than the complete landing report and is faster to transfer over the network.

First we can look up the web service definition:

findUserLandingReports()

The findUserLandingReports() has 23 arguments and provides a lot of functionality and flexibility.

In Netbeans, build a new method:

public void getLandingReportList(){
        try {
            Calendar fromLastModifedDate = GregorianCalendar.getInstance();
            fromLastModifedDate.set(Calendar.YEAR, 2011);
            fromLastModifedDate.set(Calendar.MONTH, 7);
            fromLastModifedDate.set(Calendar.DAY_OF_MONTH, 10);//15 no records
            fromLastModifedDate.set(Calendar.HOUR_OF_DAY, 0);
            fromLastModifedDate.set(Calendar.MINUTE, 0);
            fromLastModifedDate.set(Calendar.SECOND, 0);
            fromLastModifedDate.set(Calendar.MILLISECOND, 0);

            DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();

            XMLGregorianCalendar fromLastUpdateDateArg = (null == fromLastModifedDate) ? null : datatypeFactory.newXMLGregorianCalendar((GregorianCalendar) fromLastModifedDate);

            String xml = svc.findUserLandingReports001("amarx", "A_marx", "2.1", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, fromLastUpdateDateArg, null);
           System.out.println(xml);

            LandingReportInfo summary = new LandingReportInfo();

            javax.xml.bind.JAXBContext jaxbCtx = javax.xml.bind.JAXBContext.newInstance("generated");//summary.getClass().getPackage().getName());
            javax.xml.bind.Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();

            StreamSource s = new StreamSource(new StringReader(xml));
            summary = (LandingReportInfo)unmarshaller.unmarshal(s);

            int size = summary.getLandingReportSummary().size();
            for(int x = 0; x<size; x++){
                String landingReportId = summary.getLandingReportSummary().get(x).getLandingReportId().getValue().toString();
                System.out.println((x+1) + " "+ landingReportId);
            }

        } catch (JAXBException ex) {
            Logger.getLogger(ElandingsClient.class.getName()).log(Level.SEVERE, null, ex);
        } catch (DatatypeConfigurationException ex) {
            ex.printStackTrace();
        }
    }

If we run this we get a long list of landing_report_info xml objects followed by the JAXB object list of landing report ids.

Using this approach, a developer can ask eLandings for all the landing reports that have been updated in eLandings since the last time the system was asked by the developer's code. The developer can then iterate through the list and call additional web service methods to get a complete copy of each landing report from elandings.
There is a lot in this method. We recommend that you study and understand it.