function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DuodouDuodou 

problem with Metadata API retrieve()--"Non nillable element 'version' is null"

Hello,


I converted Simon's sample code from http://www.pocketsoap.com/weblog/category/_net.htm l to java to retrieve report metadata.



Got an errors saying "Non nillable element 'version' is null" but I did set the version already..(My project is stuck because of this..:-( please, can anybody help me out..Thanks!)..


here is my code:

@SuppressWarnings("static-access")
    public void retrieveReports(String[] reportFiles) {
        // build up an unpackaged retrieve request for the list of reports.
        RetrieveRequest r = new RetrieveRequest();
        r.setApiVersion(API_VERSION);
        r.setUnpackaged(new _package());
        PackageTypeMembers m = new PackageTypeMembers();
        m.setName("Report");
        m.setMembers(reportFiles);
        r.getUnpackaged().setTypes(new PackageTypeMembers[] { m });
        
        // start the retrieve request
        AsyncResult ar;
        try {
            ar = this.metadatabinding.retrieve(r);
//error out:  "Non nillable element 'version' is null" :-(
            // wait for it to complete, sleeping as necassary...

... ...


Below are detailed error messages...



ERROR | 17:00:08.321 | Exception: | BeanSerializer.java
java.io.IOException: java.io.IOException: Non nillable element 'version' is null.
    at org.apache.axis.encoding.ser.BeanSerializer.serialize(BeanSerializer.java:275)
    at org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1502)
    at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:978)
    at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:732)
    at org.apache.axis.encoding.ser.BeanSerializer.serialize(BeanSerializer.java:230)
    at org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1502)
    at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:978)
    at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:799)
    at org.apache.axis.message.RPCParam.serialize(RPCParam.java:208)
    at org.apache.axis.message.RPCElement.outputImpl(RPCElement.java:433)
    at org.apache.axis.message.MessageElement.output(MessageElement.java:1208)
    at org.apache.axis.message.SOAPBody.outputImpl(SOAPBody.java:139)
    at org.apache.axis.message.SOAPEnvelope.outputImpl(SOAPEnvelope.java:478)
    at org.apache.axis.message.MessageElement.output(MessageElement.java:1208)
    at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:315)
    at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:269)
    at org.apache.axis.SOAPPart.saveChanges(SOAPPart.java:530)
    at org.apache.axis.SOAPPart.getContentLength(SOAPPart.java:229)
    at org.apache.axis.Message.getContentLength(Message.java:510)
    at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:371)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at com.sforce.soap._2006._04.metadata.MetadataBindingStub.retrieve(MetadataBindingStub.java:2121)
    at centtric.cloudfill.adapter.SalesforceMetaDataAdapter.retrieveReports(SalesforceMetaDataAdapter.java:111)
    at centtric.cloudfill.adapter.SalesforceMetaDataAdapterTest.testGetReportList(SalesforceMetaDataAdapterTest.java:15)


Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

The Package object that you set on the unpackaged property also have a version element, that's the one that's generating the error.

All Answers

DuodouDuodou

Forgot to mention that I am using Axis 1.3. I know Axis 1.3 would complain if there is null in the message element..the part I can't understand is I have set version to 18.0...why it is still complained..Please help..

 

 

Thanks and regards,

 

Duodou

SuperfellSuperfell

The Package object that you set on the unpackaged property also have a version element, that's the one that's generating the error.

This was selected as the best answer
DuodouDuodou

You are the best! That solves the problem...the reports.zip is generated..but it only contains report folder..don't see any reports. Could please review my code blow and point out what the cause could be. Thanks a lot!

 

Also, thank you for posting the .Net sample that I am following..that is the best and the only one I can find for retrieving reports metadata.Great work!

 

*********************************************

@SuppressWarnings("static-access")
  
 public void retrieveReports(String[] reportFiles) {        // from debugger I can see that reportFiles is correct..
        // build up an unpackaged retrieve request for the list of reports.
        RetrieveRequest r = new RetrieveRequest();
        r.setApiVersion(API_VERSION);
        r.setUnpackaged(new _package());
        PackageTypeMembers m = new PackageTypeMembers();
        m.setName("Report");
        m.setMembers(reportFiles);
        r.getUnpackaged().setTypes(new PackageTypeMembers[] { m });
        r.getUnpackaged().setVersion("V1.0");
        
        // start the retrieve request
        AsyncResult ar;
        try {
            ar = this.metadatabinding.retrieve(r);
            // wait for it to complete, sleeping as necassary.
            while (!ar.isDone()) {

                Thread.currentThread().sleep(3000);
                ar = this.metadatabinding
                        .checkStatus(new String[] { ar.getId() })[0];

            }

            // did it work ?
            if (ar.getState().toString() == AsyncRequestState._Error) {
                System.out.print(ar.getStatusCode() + ar.getMessage());
            } else {
                 // now actually go get the results
                RetrieveResult rr = metadatabinding.checkRetrieveStatus( ar.getId());
                if (rr.getMessages() != null){
                     for (RetrieveMessage rm :rr.getMessages()){
                        
                         System.out.println(rm.getFileName() + rm.getProblem());
                     }
                }
                
                // Write the zip file to disk
                String file_name = "c:\\reports.zip";
                FileWriter file = new FileWriter(file_name);
           
                BufferedWriter out = new BufferedWriter (file);
                out.write(new String( rr.getZipFile()));
                out.close();
            }
            
        } catch (RemoteException e) {
            e.printStackTrace();
        } catch (InterruptedException e1) {
            e1.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

 


@SuppressWarnings("unchecked")
    public String[] getReportList() {
        ListMetadataQuery q = new ListMetadataQuery();
        q.setType("ReportFolder");

        try {
            FileProperties[] fp = metadatabinding.listMetadata(
                    new ListMetadataQuery[] { q }, 0);

            if (fp == null) {
                System.out.println("No report folders returned");
                return null;
            }

            List<String> reportFiles = new ArrayList();

            q.setType("Report");
            for (FileProperties p : fp) {
                q.setFolder(p.getFullName());
                // listMetadata can take more than one item at a time
                // left as an exercise for the reader to batch up these calls.

                FileProperties[] rps = metadatabinding.listMetadata(
                        new ListMetadataQuery[] { q }, 14.0);
                if (rps == null) {
                    continue;
                }
                for (FileProperties rp : rps) {
                    System.out.println("MY DEBUG OUTPUT....rp.getFileName()=" + rp.getFileName());
                    reportFiles.add(rp.getFullName());
                }

            }
            return (String[]) reportFiles.toArray(new String[0]);

        } catch (RemoteException e) {
            e.printStackTrace();
        }

        return null;

    }

DuodouDuodou

Never mind...I have figured it out by my self...I should use FileOutputStream instead of FileWriter..:-)

New code:

  // Write the zip file to disk
                String file_name = "c:\\reports_1.zip";
                FileOutputStream fileOutput = new FileOutputStream(file_name);
                fileOutput.write(rr.getZipFile());
                fileOutput.close();

 

 

Cheers,

 

Duodou