Wang Shi (王式) was an official and general of the Chinese dynasty Tang Dynasty, known for his campaign against Nanzhao forces to retain the control of the Annan (i.e., modern northern Vietnam) region, and his campaign against the agrarian rebel Qiu Fu (裘甫).
It is not known when Wang Shi was born. His biographies in the official histories of Tang Dynasty — the Old Book of Tang and the New Book of Tang — differ as to who his father was, with the Old Book of Tang indicating that his father was the chancellor Wang Bo and the New Book of Tang indicating that his father was Wang Bo's brother Wang Qi (王起), who also had a lengthy career as an imperial official.
Because of his heritage, Wang Shi was made a scribe for the Crown Prince, and he later passed, in 828, during the reign of Emperor Wenzong, a special imperial examination for those who are considered wise and righteous. He was later made an imperial censor with the title Dianzhong Shiyushi (殿中侍御史). He was considered frugal in his youth. However, in the middle of Emperor Wenzong's Taihe era (827-835), Wang, who was considered ambitious, tried to achieve greater offices by associating with the powerful eunuch Wang Shoucheng and Wang Shoucheng's associate Zheng Zhu, and when the deputy chief imperial censor Gui Rong (歸融) submitted an accusation against him on that basis, he was sent out of the capital Chang'an to serve as the deputy mayor of Jiangling.
During the Dazong era (847-860) of Emperor Wenzong's uncle Emperor Xuānzong, Wang Shi served as the prefect of Jin Prefecture (晉州, in modern Linfen, Shanxi). At that time, there was a major famine in the Yellow River bend area (i.e., modern northern Shaanxi and central-western Inner Mongolia), and the refugees spread throughout the region. Few prefectures welcomed the refugees, but Wang did, and it was said that several thousands were saved because of his actions. The non-Han tribes of the region also suffered from the famine and were pillaging the cities, but after hearing that Wang was defending Jin Prefecture carefully, avoided attacking Jin Prefecture.