They are in the US Army. They are wearing leggings of the kind that was worn from 1903 to the early part of WWII. The army changed the legging design in the 1930 slightly, but the older leggings were still issued.
The one soldier is wearing a campaign hat, which was also worn up to WWII, which the other soldiers are wearing pith helmets, which was made of cloth, was worn to about 1910. It was mostly in topic climate and mostly in the Panama Canal. This was the kind that was worn during the US involvement during the Boxer Rebellion. The design was changed sometime prior to WWI when it was changed to a rounder style (most likely around 1910).
The rifle in the picture looks like a Krag (1880's) or possibly a Springfield (1898-1903), which also dates the photo to prior to 1941 the Krag was carried up to just before WWI, when the army change to the Springfield. The Springfield was carried up to the early part of WWII. One of the soldiers in the top row is a corporal, possibly in the Quartermaster Corps (but is is hard to make out the bottom part of the rank insignia, but usually only the Quartermaster and Medical Corps had an insignia below the stripes.
The building behind them appears to be a Headquarters building since it has bars on one of the windows. The bars were used to protect the armory or pay clerk's office and was usually in the HQ building for added security. The building is pre-WWI, since the design style of the army building changed.
All in all, I would estimate that the photo was taken sometime between 1898 and 1910.