Expose a soap api with 40 parameters

apisoapsoap-api

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

Best Answer

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.

Related Topic