The cabin is usually pressurized to the equivalent of 8000 ft asl. So the dispenser does have to deal with pressure changes. A simple vent hole aught to take care of that though.
Also, as the safety briefing says, “we do not anticipate a change in cabin pressure,” but if a rapid decompression should occur, there was probably some provision made so that the soap dispenser doesn’t just shatter or explode or something.
I would hate not to be able to use the dispenser if the plane lost cabin pressure… how would I ever survive dying if I had dirty hands when it happened?..