Context: Service virtualization has become a popular tool to provide testing environments for highly connected enterprise software systems. It enables the enterprise system under test to interact with and obtain responses from model-based service emulations instead of the actual services they use in production environments, providing accessibility and realness. Existing approaches consider only the control dependencies between messages (i.e., the service's control model) and do not consider the relationships between data values of the messages (i.e., the service's data model), limiting the accuracy of service emulation. Objective: In this paper, we present an approach to deriving the service's data model from its interaction traces and using it in determining the payloads for response messages, therefore achieving more accurate service emulation. Method: The derivation of a service's data model is achieved by discovering the data entities and their key attribute(s) from the service interaction messages. It is then used, together with the control model, to synthesize response messages for incoming request messages at runtime. While the control model help to identify the types of responses, the data model keeps track of the changes to the service's data entities and provides the basis for populating accurate payloads for the responses. Results: A number of experiments have been conducted on message traces collected from a range of stateful and stateless services. With the use of both the control and data models in response generation, our approach consistently outperforms the existing state-of-the-art approaches. In particular, it generates 100% identical responses (compared to actual services) for most of the datasets, while the highest accuracy achieved by existing approaches was 88%. Conclusion: The experimental results have shown that the inferred data model provides an effective means in determining the payloads for response messages, significantly improving the accuracy of service emulation and providing more realistic testing environments.