In recent years, service-based applications are deemed to be one of the new solutions to build an enterpriseapplication system. In order to answer the most demandingneeds or adaptations to the needs of changed servicesquickly, service composition is currently used to exploitthe multi-service capabilities in the Information Technologyorganizations. While web services, which have been independently developed, may not always be compatible with each other, the selection of optimal services and compositionof these services are seen as a challenging issue. In this paper we propose optimal web service composition (OWSC) model, we introduce an improved Dragonfly Algorithm (IDA) to compute services whose network positions are closer to each other and to the users, which ensures the QoS of web service and network. The rule search swarm searcher (RSSA) is used to obtain the desirable characteristics from composite web services for further optimal selection of service composition set in composite planner. Then, we propose optimal tree based replanning mechanism to adapt the execution plan to the actual behavior of already executed services by a dynamic service selection at runtime.Finally, the proposed OWSC model is going to develop by cloudsim toolkit and the performance is compared with the existing models similar to our contributions in terms of QoS parameters.