The ruling effectively puts an end to a decades-old system that granted ultra-Orthodox men broad exemptions from military service.