REDMOND, Wash. — Microsoft Corp. is buying Nokia Corp.’s line-up of smartphones and a portfolio of patents and services in an attempt to mount a more formidable challenge to Apple Inc. and Google Inc. as more technological tasks get done on mobile devices...