Communist China supplies much of the soap and toilet paper used here. It built this country's national theater, newest children's hospital and longest road. But those are not the reasons for President Mohammed Siad Barre's trip to Peking last week.

On the contrary, having broken already with the Russians, the president went to Peking as a way of turning his back on the United States and its Arab allies. He made a bolt for nonalignment, and the reasons are worth examining as they throw light on the recent and drastic slipping of Americn influence around the Horn of Africa.

The Horn is a metaphorical term for two countries - Ethiopia and Somalia - which fringe the southwestern coast of the passage between the Red Sea and the Indian Ocean. It has long been deemed strategic real estate - the more so since the flow of oil from the Persian Gulf through the Red Sea to the United States and Europe became so important.

Maintaining influence in the Horn has been a tricky business because of bitter and unceasing conflict over the Ogaden Province, which Ethiopia now holds and Somalia claims. During most of the postwar period the United States stood with Ethiopia and Emperor Haile Selassie. The Somalis made an alliance with Russia, and began acquiring arms for another bash at the Ogaden.

In 1974, however, Haile Selassie was overthrown by a group of officers known as the Dergue. By 1976 the Dergue was clearly moving toward socialism and away from the American tie. The Russians saw their chance and began to shift toward Ethiopia at the expense of Somalia.

The Somalis tried to beat them to the punch. In July of last year President Siad Barre authorized a major offensive against the Ogaden. During August the going was good. But the Russians moved in huge amounts of supplies and thousands of Cuban troops. In September, they blocked the Somali advance. Last month they routed the Somalis and drove them from the Ogaden.

For the past year Siad Barre had been making friendly gestures toward the Americans and the anti-Soviet Arab States. But the warmup never got very far. These are the reasons as seen from the Somali side.

The case against the Americans was made to me by Adnan Mohammed, a leading theorist for Siad Barre. He told me: "America changed its mind seven times. First President Carter said he would do 'anything' to help us. Then he said the United States wanted to take Russia's place as the most influential power in this country.

"Then he offered us arms 'in principle.' Then he insisted the arms could be only defensive. Then he refused us arms for the Ogaden. The he said it would surely come if the Ethiopians and Russians invaded Somalia. Finally he said we had to renounce forever all claims to other states including Ogaden. That's too much."

As to the Arabs, Saudi Arabia promised money if the Somalis broke with the Russians, and Egypt and the Sudan were supposed to use the money to furnish arms. But Egypt could spare little from its two-front struggle against Libya and Israel. The Sudan was loath to be active against Ethiopia with its Christian population for fear of touching off a new revolt among the Christians dominant in the southern Sudan.

The Saudis have maintained here an ambassador who received his post because he was brother-in-law to ex-king Feisal's physician. He is a Syrian, and the second and third members of his mission come from the Yemen and India, respectively.

According to the Somalis, the Saudi mission took more than it gave. The take included a rake-off on aid funds for the buiding of Mosques, and an illegal mark-up of the fees for visas given Somalis seeking work in Saudi Arabia.

With friends like that, the Somalis not surprisingly found newttral status attractive. The result is that the Russians command through the Ethiopians a place of influence around the Horn, while the West and its friends hace missed out on the usual compensation in Somalia.

That is not the end of the world nor even the end of a chance for some influence around the Horn. In time, the Ethiopians may tire of the Russians and turn to the West. But not unless the Arabs learn to be a little more serious in their diplomacy and President Carter a little more steady in his policy.