Armed militants attacked a major Indian army base near the border with Pakistan, killing two soldiers, police says.