Magnetic field problem with axial symmetry and its solution in terms of Fourier-Bessel expansions