The movie you are referring to is "Toy Story", a 1995 animated film directed by John Lasseter. The movie follows the story of a toy cowboy, Woody, and a toy space soldier, Buzz Lightyear, who become friends and embark on an adventure.
The movie that is about a toy cowboy and a toy space soldier who become friends is called Toy Story. It was released in 1995 by Pixar Animation Studios and directed by John Lasseter. The movie revolves around the life of a boy named Andy and his toys. The main characters of the movie are Woody, a cowboy toy that is Andy's favorite, and Buzz Lightyear, a space ranger toy that Andy receives as a birthday gift.