3

While trying to Generate MetadataService classes using the standard Metadata API WSDL from Salesforce, classes I got below error. I think it is related to the length of the Apex class as the lines of code in MetadataService class are more than 13K.

I downloaded the WSDL file from Setup -> API -> Generate Metadata WSDL

Error: Script too large: public class MetadataService { public class ReportTypeColumnTranslation { public Strin... at 3:14

enter image description here

  • 1
    FYI, there is an upper limit of 1,000,000 characters in a class, which is the error you're seeing. – sfdcfox May 1 at 23:53
3

When I've wanted to invoke this API from Apex in the past I have used this already generated and modified code:

Apex Wrapper Salesforce Metadata API

though it looks like it hasn't have much attention in recent years. It does support at least this version of the API:

Summer'16 v37.0 Metadata API

and probably v42.0 based on commit comments.

The list of changes it applies to make the API work from apex is listed here MetadataServicePatcher.cls line 28, though no mention of the class size limit being hit. But additions to the WSDL since v37/v42 may be causing that.

The Tooling API can be accessed via JSON REST calls so does not require any generated code to use. If the operation you want to invoke is present in that API, it is a lot easier to use.

| 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.