The paper proposes a method for measuring complex permittivity and permeability of small semiconductor samples using two spherical microwave cavities. When a spherical sample is placed at the centre of the cavity the electromagnetic fields can be solved exactly, except for unimportant amplitude coefficients in the whole interior of the resonator. Consequently the complex resonant frequencies of different cavity modes have analytic solutions in terms of electric and magnetic material parameters of the sample. The parameters can then be calculated from the measured resonant frequencies and quality factors of two spherical cavities; further more the accuracy of the results is limited only by the accuracy of the measurements. In addition, the exact solutions give an opportunity to check the validity of the ordinarily used cavity perturbation theories.