On the rear axle, this is done by removing (4) 1/4" bolts and (2) steel retaining straps from the differential output yoke.
At the transfer case, simply pull the driveshaft out of the slip yoke.
Some oil may spill from the transfer case when the shaft is removed, but not a lot.
The transfer case will look like this with the driveshaft removed.