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, using one or more processors, from the workflow a local part to be executed on the device, wherein generating the local part comprises: modifying partner links in the workflow in order to specify coherent partner links; deleting at least part or all task activities in the workflow that do not belong to the local part, while keeping dependencies specified by process control activities; and simplifying the routing and process control activities in the workflow; 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 more identifications of one or more next devices by matching a role to capabilities of the one or more next devices, the role being a set of attributes of the one or more next devices, the set of attributes being used to execute next task activities associated with a next local part on the one or more next devices; and sending one or more messages representing a next routing activity to the one or more next devices thus identified.