For Web services to expand across the Internet, users need to be able to efficiently access and share Web services. The authors present a query infrastructure that treats Web services as first-class objects. It evaluates queries through the invocations of different Web service operations. Because efficiency plays a central role in such evaluations, the authors propose a query optimization model based on aggregating the quality of Web service (QoWS) parameters of different Web services. The model adjusts QoWS through a dynamic rating scheme and multilevel matching in which the rating provides an assessment of Web services' behavior. Multilevel matching allows the expansion of the solution space by enabling similar and partial answers.