For a new president in his first major legislative skirmish, the episode revealed something about Congress and the loyalty and reliability of individual members, White House officials said.

“Part of it is trying to figure out as you go down this path who you can rely on and who’s going to keep your word,” White House Press Secretary Sean Spicer said after the bill was scuttled. “Who’s going to negotiate in good faith? We dealt with over 120 members of Congress and you learn a little about some of these individuals.”

He added: “Some people kept saying, ‘I’m trying to get with you,’ and then they’d come back day after day and say, ‘Here’s the next thing I need.’ The reservoir never got dry.”

As the White House now moves onto other legislative priorities, it can potentially draw on the lessons gleaned from the health care debacle.

“You just learn a lot about who you can count on and who you can’t,” Mr. Spicer said.

Asked about the president’s mood following the setback, Mr. Spicer said: “He’s doing great. He feels confident that he put everything out there.”

In the end, Mr. Trump accepted House Speaker Paul Ryan’s assessment Friday that the bill would fall short by up to a dozen votes, thus making a vote in the House unnecessary, Mr. Spicer said.

“Paul came up and gave him a read-out of what the situation was and he made a decision,” Mr. Spicer said.