Array does not exist in webapi

Array does not exist in webapi

The Magento 2 webapi is very useful to publish entities to the world.
One big advantages of the new webapi is the automatic generation of a swagger schema for RESTful API.
If you prefer SOAP over REST you should also be happy to heat that Magento 2 will automatically generate all the WSDL stuff.

Magento 2 analyses all the published classes/methods via PHP reflection.
Any generated WSDL file contains a XSD with all the types used in the webservices.

In some cases the generation stops with the following error message:

What’s up with this message?

As written before we need a type for each object which is used in a SOAP service.
SOAP services are type strict! PHP is not really type strict in any case.
It’s possible to return mixed content in any PHP function.

If you see this message the Reflection API cannot analyse the type. It expects a real type.

To solve the problem look inside the published classes inside your etc/webapi.xml configuration file.
Check if there is something like @return mixed or @return array. Also check all @param annotations and used sub-classes.

Wrong declerations:


If you need an array of scalar values you can use the following syntax which could be parsed by the automatic WSDL generation:

It’s possible to replace “string” with any scalar or complex type.

We hope this tips can help you safe a lot of time investigating the error message.

One thought on “Array does not exist in webapi

Leave a Reply to Siju AS Cancel reply

%d bloggers like this: