The capillary forces exerted by liquid drops and bubbles on a soft solid are directly measured using molecular dynamics simulations. The force on the solid by the liquid near the contact line is neither oriented along the liquid vapor interface nor perpendicular to the solid surface, as usually assumed, but points towards the liquid. It is shown that the elastic deformations induced by this force can only be explained if, in contrast to an incompressible liquid, the surface stress is different from the surface energy. Using thermodynamic variations we show that the surface stress and the surface energy can both be determined accurately by measuring the deformation of a slender body plunged in a liquid. The results obtained from molecular dynamics fully confirm those recently obtained experimentally [Marchand et al., Phys. Rev. Lett., (2012), 108, 094301] for an elastomeric wire.