Public perceptions may lump all 535 House and Senate members together in a great ball of sleaze, but in the real world of Capitol Hill it is not that way.

Congress, reflecting the larger world it represents, has its white hats and black hats. When Wayne Hays toppled, there was institutional glee; to his peers the Ohio Democrat symbolized the black hats.

But it is a jolt when the white hats' pedestals are sent reeling around the congressional pantheon. The air of taint reaching Rep. Frank Thompson (D-N.J.) and Sen. Harrison A. Williams Jr. (D-N.J.) will jolt Congress.

Thompson and Williams, both involved in the FBI "sting" probe of alleged favors for money on the Hill and elsewhere, are among the more readily indentifiable white hats.

Both men hold major committee positions and both have played key roles in the development of the social legislation that has affected millions of Americans during the past two decades.

Both have been strong supporters of the causes of organized labor and both remained mainstream liberals in and era when it became increasingly difficult.

Thompson, particularly, has been a leader in the efforts in reform House operating procedures -- partly fall-out from the Hays peccadilloes -- and to tighten congressional campaign finance law.

Last fall, the white-haired Thompson laid it out succinctly during debate on the campaign law. "The House needs to be taken off the auction block before the 1980 election," he said, in a sort of manifesto for the white hats.

The immediate and obvious irony, of course, is that white hats have been swept up indiscriminately in an FBI net of allegation with others whose institutional reputations range from gray to black.

Thompson was elected in 1954 from a traditionally Democratic district of central New Jersey, with Trenton, his hometown, as his political base.

He had not been in Congress long before he and other liberals got together to form the Democratic Study Group, a forum that eventually played an influential role in turning the House against the Vietnam war and promoting procedural reforms.

Thompson was plugged in well with his party's structure. In 1980 John F.

Kennedy named him to head a register-the-vote campaign. He and Rep. Richard Bolling (D-Mo.) then teamed up to help Kennedy and Speaker Sam Rayburn reshape the Rules Committee and get New Frontier programs moving.

The Thompson-Bolling alliance continued when the New Jersey congressman managed Bolling's abortive campaign for majority leader after Rayburn died.

Bolling went on to head the Rules Committee and Thompson succeeded to chairmanship of the House Administration Committee after Wayne Hays' fun and games with Elizabeth Ray were exposed.

Thompson has run the Administration Committee with a more benevolent hand than Hays and used his position to promote public financing of congressional campaigns -- an effort that has not succeeded.

Nationally, however, Thompson's reputation stems from his role as the second-ranking Democrat on the Education and Labor Committee.

During his tenure on the panel, and with his strong support, dozens of pieces of social legislation have started on their way to becoming law -- from job safety and school lunch programs to help for the arts and job-creation schemes.

A lobbyist for a major labor organization yesterday described Thompson and Williams this way: "They are not so much friends of labor as they are supporters of important social legislation. They speak for working people on those social programs, and these are the things that draw us together -- not our good looks."

Thompson, 61, is tall, debonair and regarded as a raconteur par excellence, occasionally given to heavy drinking, although recent health problems have crimped his style somewhat. His colleagues call him "Tompy."

There is a certain parallel with Harrison Williams' career. Williams, 60, preceded Thompson to Congress by a year, serving 2 1/2 terms in the House, then moving to the Senate in 1958.

In the late 1960s, as whispers grew to a small din, Williams brought his own drinking problem out of the closet, calling a campaign-period press conference to admit it and to announce that he was whipping it.

Seniority propelled him to the chairmanship of the Labor and Public Welfare Committee (now Labor and Human Resources) by 1971, after much of the big social legislation had been passed.

But he has made a mark nonetheless as a senatorial champion of labor's underdogs, working for mine safety reform, greater ocupational safety, more low-cost housing and rapid transit for big cities.

Like Thompson, Williams over the years has received high marks from the AFL-CIO's Committee on Political Education and Americans for Democrataic Action for his liberal stance on public issues. And like Thompson, he prefers to be known by a nickname -- Pete.

Out on the fringes of Capitol Hill, among the interest groups, they rather expect the black hats to be caught in the webs, sooner or later. It's a little tough, as one public-interest lobbyist put it yesterday, when the white hats are drawn in.

"This stuff knows no ideology," he said.