Security and trust are fundamental challenges when it comes to the deployment of large wireless sensor networks. In this paper, we propose a novel hierarchical trust management scheme that minimizes communication and storage overheads. Our scheme takes into account direct and indirect (group) trust in trust evaluation as well as the energy associated with sensor nodes in service selection. It also considers the dynamic aspect of trust by introducing a trust varying function which could give greater weight to the most recently obtained trust values in the trust calculation. The proposed framework can be extended to such dynamic mobile inter-cluster wireless sensor network environments.