Modern production lines are often composed of machinery from different vendors that must be connected with each other to increase the overall interoperability and flexibility. A common problem that arises in such systems is the complexity of the configuration task: they usually require each component to be manually configured. Thus, machinery requires different configuration strategies, negatively impacting scalability and increasing the chance of human errors. Furthermore, each time the manufacturing system has to be updated, the entire procedure must be repeated. This paper proposes a software architecture abstracting the complexity of existing production lines by enabling the service-oriented manufacturing paradigm. Then, it presents a strategy to model manufacturing systems, covering the topology of the production plant, machinery, and production recipes. The paper also proposes a model-based methodology to automatically configure the reference software architecture and hence the machines in the system. The application of the contributions to a fully-fledged production line shows the effectiveness of relying on model-based automatic configuration.