1. A method for executing a workflow on a device, the workflow comprising one or more task activities comprising actions performed by devices participating in the workflow and routing activities used to transfer control and data between devices, the workflow further comprising roles, wherein the method comprises: receiving a message representing an incoming routing activity; generating from the workflow a local part to be executed on the device; executing task activities comprised by the generated local part on the device; performing a request to a discovery service in order to obtain one or several identifications of next devices by matching a role to capabilities of the device; and sending one or more messages representing a routing activity to the one or more next devices thus identified.