Educated at Cheltenham College, Longley was commissioned into the East Surrey Regiment in 1887 and served in South Africa in 1902, towards the end of the Second Boer War. In 1911 he was appointed Commanding Officer of 1st East Surreys and went to France in August 1914 at the start of World War I, fighting in the battles of Mons, Le Cateau, the Marne, the Aisne, La Bassée and Armentières. In early 1915 he was appointed Commander of 82nd Infantry Brigade and in December 1915, with the rank of Major General, he became the General Officer Commanding 10th (Irish) Division.