BEIJING — The two men smiled as they strolled amid the swaying palm trees. They dined on pan-seared Dover sole, aged prime strip steak and Sonoma Coast Chardonnay beneath glimmering chandeliers. They shared an antique sofa for the group photo with their wives.

President Trump and China’s President Xi Jinping were calling each other friend by the end of their springtime retreat at Trump’s Florida club, Mar-a-Lago — a relationship that would have been unimaginable months earlier. During his campaign, Trump complained Xi was “ripping us off,” threatened him with trade sanctions and vowed that the closest he would come to a state dinner was a trip to McDonald’s.

On Monday in Japan, Trump expressed his new view: “I like him a lot. I consider him a friend. With that being said, he represents China; I represent the United States.”

Expect the the good times to continue.

After arriving Wednesday afternoon, Trump and first lady Melania Trump are scheduled to join Xi and his wife, Peng Liyuan, for tea, a tour of the ancient Forbidden City, an opera performance and dinner.

The Chinese, much like the Japanese and South Koreans on the first two stops of Trump’s five-nation Asia tour, believe the gilded treatment is the best way to play to Trump’s ego and disarm him, and thereby blunt his demands that China open up its economy and take a harder tack against North Korea, according to experts and former government officials.

Trump’s dynamic with Xi, however, is easily the most consequential of all his foreign relations, politically and diplomatically, given China’s greater prominence, — its economy is second in size only to the United States’ — as well as its superpower aspirations and the centrality of Trump’s past China attacks to his election.

“The Chinese strategy will be to treat Trump with enormous respect and give him nothing,” said David Dollar, the U.S. Treasury Department’s economic and financial emissary to China from 2009 to 2013 and now a scholar at the Brookings Institution.

The Trump administration insists it is getting what the president wants from China, especially as the two nations work to further isolate North Korea in hopes of halting that provocative country’s drive toward nuclear-armed intercontinental ballistic missiles.

Before leaving South Korea for Beijing, Trump said Xi “has been very helpful. We’ll find out how helpful soon. But he really has been very, very helpful.”

H.R. McMaster, Trump’s national security adviser, said China, North Korea’s patron and primary trading partner, now understands the breadth of the threat that Pyongyang poses.

Now, McMaster said, “everyone acknowledges, China especially,” that “this is a problem between North Korea and the world.”

Trump, during a news conference in Japan on Monday, said he would be working to alter the “very unfair trade situation” and promised “very, very strong action” against unnamed countries that he said were mistreating U.S. workers. Yet, a year after his election, Trump still was not specific about what he hoped to accomplish with Xi.

Analysts say Trump will need to strike a balance — continuing to treat Xi as a friend without compromising American interests or appearing too deferential. Their meeting comes at a time when Xi would seem to have the advantage: While Trump is weakened by scandal, legislative setbacks and low poll ratings, China’s Communist Party recently granted Xi powers not seen since Chairman Mao Zedong’s rule a half-century ago.

“What the president needs to do is not come in and sort of anoint the pope,” said James Jay Carafano, a foreign policy and defense specialist at the conservative Heritage Foundation who has advised Trump. “On the other hand, nobody wants the thing to melt down either.”

Xi is known for his ability to engage others on a personal level, beyond simple talking points, by virtue of extensive preparation.

“He’s not needy. He rarely if ever asks for anything,” said Ryan Hass, a career diplomat who accompanied Obama to meetings with Xi. “It’s more of a peer-to-peer discussion for how the two leaders see the world.”

Hass said that style likely appeals to Trump, “who otherwise comes into contact with a lot of people who are making requests.”

Noah Bierman reported from Washington and Brian Bennett from Seoul and Tokyo. Staff writer Jonathan Kaiman and special correspondent Gaochao Zhang in Beijing contributed.

noah.bierman@latimes.com