A service-oriented architecture for dynamic macroprogramming of sensor networks