ON THE X-RAY SPECTRA OF ANOMALOUS X-RAY PULSARS AND SOFT GAMMA REPEATERS