1

I am creating an application for Salesforce Integration. I am trying to retrieve the installed packages from a particular account as I am able to do by using APEX class but now I want to retrieve the installed packages using PARTNERWSDL. Can any pleae help me in this regards. Thanks in advance.

MetaDataWSDL.ListMetadataQuery query = new ListMetadataQuery(); 
query.type = "InstalledPackage"; 
double asOfVersion = 29.0; 
MetadataService mBinding = new MetadataService(); 
mBinding.SessionHeaderValue.sessionId = binding.SessionHeaderValue.sessionId;  
FileProperties[] lmr = mBinding.listMetadata(new ListMetadataQuery[] { query }, asOfVersion);

Here i am getting the value as null. and I have specified the version as 29.0. May i know how can i know my version number when i am using OAuth authencation.

4
  • Do you mean that you want to access data from objects and fields defined in the installed packages using the Partner WSDL?
    – Keith C
    Commented Mar 26, 2014 at 10:00
  • thanks for your reply. YES I want to know what are the objects and fields specified in the installed packages as well as all the package names that are installed under a account. Like I have installed some packages from appexchange.salesforce.com and now I want to retrieve all those packages in my application. So what should be the namespace and class for getting the installed packages. Commented Mar 26, 2014 at 10:15
  • or if there would be any SOQL query for finding the installed managed application. Like when we are using MetadataAPI we are executing the .request() with RetrieveRequest object. Commented Mar 26, 2014 at 13:49
  • I suspect (but am not sure) that the MetaData API is the appropriate one to obtain information about installed packages so you may have to generate client code for both APIs.
    – Keith C
    Commented Mar 26, 2014 at 13:55

1 Answer 1

3

The Salesforce Metadata API is the only API that will do this for you. You can use the listMetadata operation to accomplish this, here is a previous question with answer detailing this, How to get a list of the managed packages (including version numbers) installed in an org?. If your interested in doing this from Apex, you can find a library that exposes the listMetadata method to Apex here.

Note: This applies only to managed packages installed in the org

Regarding update Java Code in Question

It looks like your not initialising mBinding.SessionHeaderValue? If you take a look at how this variable is defined it is likely you need to construct an object to assign to it, then assign the session Id. Something like this...

MetadataService mBinding = new MetadataService(); 
mBinding.SessionHeaderValue = new MetadataService.SessionHeader(); // < Something like this?
mBinding.SessionHeaderValue.sessionId = binding.SessionHeaderValue.sessionId;  
8
  • Thanks for your reply. I have tried the above process but I am getting the record as null. kindly check the below mentioned code What actually i did :- MetaDataWSDL.ListMetadataQuery query = new ListMetadataQuery(); query.type = "InstalledPackage"; double asOfVersion = 29.0; MetadataService mBinding = new MetadataService(); mBinding.SessionHeaderValue.sessionId = binding.SessionHeaderValue.sessionId; FileProperties[] lmr = mBinding.listMetadata(new ListMetadataQuery[] { query }, asOfVersion); Commented Mar 27, 2014 at 7:16
  • Its a bit hard to read as a comment tbh, perhaps you can update your answer? Also did you see the Java example in this answer, salesforce.stackexchange.com/questions/13561/…? Commented Mar 27, 2014 at 15:58
  • I have updated the code in my question. May i know how can we retrieve the version number Commented Mar 28, 2014 at 4:07
  • You don't say what line the null point exception is occurring on, but I've updated the answer with what i suspect is the case. Commented Mar 28, 2014 at 11:05
  • Thanks for your reply. I am already using that line, as I am not getting any exception the problem is that I am unable to retrieve the any value as I am having 1 package installed in my account. FileProperties[] lmr = mBinding.listMetadata(new ListMetadataQuery[] { query }, asOfVersion) This lmr variable is returning the null value as it is unable to find any value Commented Mar 28, 2014 at 11:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .