0

I need to expose an API Soap with 40 parameters. Do you have an idea how to do that because SF give me an error when i generate Apex Class from WSDL "Invalid number of parameters exceeds: 32".

Same issue Salesforce webservice API Input parameter limit

But my client would keep those 40 parameters as input ...

Thanks

1 Answer 1

1

Use a "wrapper" class:

global class Parameters {
  webservice String param1;
  webservice String param2;
  ...
  webservice String param40;
}
webservice static Response method(Parameters params) {
  ...
}

In general, you should consider this design for any method once you exceed about 4 parameters anyways.

Note that this a hard limit in Apex, and is related to managing the size of the call stack, since stack is a limited resource (maximum of 1000 recursive calls). In essence, the 32 parameter limit keeps the maximum stack size under 128kb of data (4 bytes of 32 parameters for 1000 stack frames).

If you don't understand the previous paragraph, it's okay. Just know that that the limitation isn't arbitrary. You need to use a wrapper class, which can hold many thousands of items, if you prefer.

3
  • Thank you sfdcfox. Do i need to declare param1..40 as webservice ? global class ParamsInput { webservice String param1; webservice String param2;... } webservice static Output myMethod (ParamsInput param){ //code }
    – Nooby
    May 9, 2022 at 16:39
  • @Nooby Just checked the documentation, and they do indeed recommend webservice. I'll edit this answer to reflect that.
    – sfdcfox
    May 9, 2022 at 16:52
  • Thank you very much! In the case of consuming a webservice which needs to pass more than 32 parameters, what we will do in SF?
    – Nooby
    May 9, 2022 at 17:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .