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.
Attribution to: Himanshu Jain
Possible Suggestion/Solution #1
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;
Attribution to: Andrew Fawcett
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/30953