A former soldier arrested on base after grooming a child online is fighting to stay out of jail, a court has been told.