2

I have requirement to expose Apex Class method as SOAP type webservice API which has more than 50 fields (input parameters) but when I try to save my code its giving me compilation error saying 'Number of Parameters exceeds maximum: 32'. Is it kind of limitation over exposing API with more than 32 input parameters? I have raised a support case to see if I can increase this limit. Any idea If I can increase the limit?

  • Can you share your code? It is not clear from your problem description – Anshul Jun 17 '15 at 21:17
6

This is a rather strange hard limit on the number of parameters a method can have in Apex. It doesn't get in the way normally - a large number of parameters is not a good approach to use - but can get in the way of some automatically generated code.

If your API has many parameters they are probably best grouped into objects in any case. So instead of a flat list of method parameters define and use classes (with class names and field names that relate to the terminology of the domain your are coding for) to group the parameters:

global class MyService {

    global class Concept1 {
        webService String s1;
        webService String s2;
        webService String s3;
        ...
    }

    global class Concept2 {
        webService Integer i;
        webService String s;
        webService Boolean b;
        ...
    }

    webservice static void myMethod(Concept1 c1, Concept2 c2, ...) {
        ...
    }
}

As well as staying within the parameter limit, this will hopefully also make your API easier to understand/use.

There is an example of this approach in Considerations for Using the WebService Keyword.

  • This is perfect solution to fight parameter limit. Thanks Keith. – JavaAster Jun 18 '15 at 13:51

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.