Often a problem for all of us! Having the reference to the army regiment is good for reference
Using the hints available:
If Sophia was born in 1864 and James was already a pensioner it implies he wasn't newly married in his early twenties
It looks as if James MULLEN was one of the witnesses at the wedding as pensioner is written after his signature on the church record; implying he was still alive in 1887
Army records are not my best area but there is one army record that is of interest that I can see
Colour Sergeant James MULLEN #1510 born in the parish of St. Ann, Dublin
Former occupation: Book binder
Attested: Cork August 21 1840
Discharged: June 17 1862
Served: 21 years 131 days of which 4 11/12 years were in India and 6½ years were in Australia
The record "Canada, British Army Regimental Rolls of Non-commissioned Officers and Soldiers, 1806-1892 for James Mullen" states the same information and also that he married on January 3rd 1848; however it does not state to whom or where.
A check on the movements of the regiment could help locate where the marriage took place and to whom
On the 1861 Army census he is listed at Taranakie New Zealand on a transcription - access to the original may show if a spouse and/or family was with him to see if he is the correct man
edited to add -
found marriage recordJames MULLIN Private in 40th Regt, Shambles Barracks (F) Patrick; servant (M) not recorded
married in the Collegiate Church of St. Nicholas Parish, Galway on Jan 3rd 1848
Mary KELLY of Mainguard Street, Galway (F) William; Private in HM Army (M) not recorded
Witnesses: John & Elizabeth McEVOY
LINK to Civil Record Reference