Efficient detection of security attacks in Wireless Sensor Networks (WSNs) is very crucial in their Intrusion Detection Systems (IDSs). This is due to the sensitivity of WSN and its strong presence in the current and future Internet of Things (IoT) services. This paper provides a comprehensive empirical study aims at examining several Data mining techniques (DMTs) using a new specialized, published dataset for WSN networks (named as WSN-DS). The purpose is to provide an efficient IDS for detecting critical Denial of Service (DoS) attacks, which have a serious impact on the services provided by WSNs. Eight DMTs are considered in this study, which were attempted firstly using all existing features in WSN-DS, and evaluated in terms of detection accuracy and time complexity. Moreover, a feature selection algorithm has been applied to reduce around 53% of overall features while attaining a high accuracy rate reaches 98% and reducing the time complexity by up to 78.37% in some techniques. Thorough performance comparison among the studied DMTs before and after the feature selection is provided. Additionally, a deep security analysis has been conducted to make decisions regarding optimizing the attack detection process and consequently protecting WSN applications from different DoS attacks. Such decisions include the best way of integrating DMTs in the IDS of WSN.