A Theory of Contracts for Web Services