WASHINGTON — President Trump turned in his chair at Mar-a-Lago to get a better look at China’s president, Xi Jinping — intent on detecting his first reaction to the news he had just dropped: American missiles were slamming into an airfield in northern Syria.

It took a few moments, but Mr. Xi’s eyes widened in surprise, and he asked his translator to repeat what was said, according to three people who spoke with Mr. Trump after that night two weeks ago. This was exactly the response he was hoping to elicit — surprise, uncertainty and a sense that the rational, predictable statecraft of President Barack Obama had given way to Mr. Trump’s more assertive vision of American power.

Mr. Trump’s confrontational and improvisational approach to foreign affairs has lifted his mood, fortunes and poll numbers in recent days. There are signs it has also made an impact on the Chinese, prodding them to finally use their leverage with their errant neighbor, North Korea.

But Mr. Trump’s mix of chest thumping and real action — the missile attack and the use of a huge bomb against Islamic militants in Afghanistan — entails serious risks overseas. It could also backfire at home, where a majority of Americans, and many of the populist conservatives who backed him in 2016, oppose long-term military commitments.