A truck bomb detonated today near a group of American soldiers who were distributing candy to children in a poor neighborhood in the eastern part of the city, killing as many as 27 people, about two dozen of them children, and wounding dozens more, government and hospital officials said.