1

I've been trying to parse the metadata WSDL provided by Salesforce to generate apex code that might help in using the metadata API. But somehow when I parse the WSDL it keeps giving me the error -

enter image description here

Does somebody have any answer to this issue?

Thanks!

0

Rather than reinventing the wheel, just install the Apex Metadata API wrapper from GitHub

You get:

  • Dozens of examples of how to retrieve and update various metadata objects (fields, listviews, etc.) See class MetadataServiceExamples.cls
  • A well-tested library that is easy to use with dozens of examples around the web, including here on SFSE. Here's a recent post by me showing some simple code
|improve this answer|||||
1

Unfortunately, in the Apexclass you've used the restricted keyword 'metadata'. Try to change(or map) this keyword to other world.

|improve this answer|||||
  • I am afraid i still am unsure about where the changes should be made. The keyword metadata is used several times in the WSDL and they might be for different purposes. I just don't want to create any more errors out of it. Could you please be a little more specific ? – Mohit Arora Jan 21 '17 at 11:56
  • Could you show the example of your code ? – Adamo Jan 21 '17 at 11:58
  • Well the apex code is not yet generated since I am unable to parse the XML/WSDL file. Here's a link to my git repository. The file is named as metadata.xml . Can you please have a look at it? Or may be try to parse it in your own org if it's not too much of a pain? Thanks in advance! Here's the repository -> – Mohit Arora Jan 21 '17 at 12:11
  • Ok. Could you explein me why you want to create Apex Class with method's which is currently implemented in the org ? – Adamo Jan 21 '17 at 14:38
  • These methods are not available in the org directly, you either have to parse a WSDL file or add the apex classes as @cropredy mentioned in his answer, unfortunately none seem to work. – Mohit Arora Jan 23 '17 at 5:28
0

Looks like I've found the solution to it.

So the GitHub repository of Andrew Fawcett has a Deploy to Salesforce button that deploys all the code to your dev org, I already had the same classes in my org but I did not pay attention to the error.

The create() method has been deprecated. I had to use createMetadata().

The code is working fine.

Thanks for the help @Adamo and @cropredy.

|improve this answer|||||

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.