We tackle the problem of providing rigorous formal foundations to current software engineering technologies for web services. We focus on two of the most used XML-based languages for web services: WSDL and WS-BPEL. To this aim, first we select an expressive subset of WS-BPEL, with special concern for modeling the interactions among web service instances in a network context, and define its operational semantics. We call WS-CALCULUS the resulting formalism. Then, we put forward a rigorous typing discipline that formalizes the relationship existing between WS-CALCULUS terms and the associated WSDL documents and supports verification of their compliance. We prove that the type system and the operational semantics of WS-CALCULUS are `sound' and apply our approach to an example application involving three interacting web services.