In prokaryotic organisms that have a slime layer or capsule, do intrinsic/extrinsic proteins and other molecules that could be used as antigens protrude through the capsule?

I assume that they must in order to maintain their function for the cell, yet am struggling to suggest another way in which the presence of a capsule/slime layer could serve as a defence against phagocytosis? Unless the slime layer directly resists lysosomal activity after the pathogen has been recognised and engulfed?
On a related note, could the flagella of an organism (which must protrude through the capsule as above) trigger an immune response on its own?