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.

  • Do you mean that you want to access data from objects and fields defined in the installed packages using the Partner WSDL? – Keith C Mar 26 '14 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. – Himanshu Jain Mar 26 '14 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. – Himanshu Jain Mar 26 '14 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 Mar 26 '14 at 13:55
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;  
  • 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); – Himanshu Jain Mar 27 '14 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/…? – Andrew Fawcett Mar 27 '14 at 15:58
  • I have updated the code in my question. May i know how can we retrieve the version number – Himanshu Jain Mar 28 '14 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. – Andrew Fawcett Mar 28 '14 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 – Himanshu Jain Mar 28 '14 at 11:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.