To find out the density, it's mass over volume. They infer the mass by the planet's distance from its star and by its orbiting speed, and they get the volume by the amount of light it takes away from the star when it pases in front of it.
It's the redshift/blueshift of the actual star that you need to measure.
That sounds hard to detect.
Well, obviously you need really precise spectrometers, but just because the effect is tiny, doesn't mean that you can't detect it.
From the density, though, you can get a pretty good idea of what it looks like. There are three basic ingredients which go into making planets: rock (including pure metals), "ice" (a catch-all term which includes all phases of water along with methane and ammonia) and hydrogen/helium mixture. Everything else is too rare to worry about. Knowing (basically) the density of each of these components, plus knowing the fact that H/He mixture won't accrete to a body until its mass goes beyond a certain point, you can put pretty good constraints on what the composition of a planet of a certain mass and radius should be.
Of course we could be wrong -- it could equally well be a ball of pure argon or something; however it's hard to imagine how any such thing would form.
I forget how you get the mass of the star, but I think it can be pretty well established from its brightness.
Maybe in a few decades, though.