An Algebraic Theory for Web Service Contracts