With the development of enterprise-wide and cross-enterprise application integration and interoperation towards web service, web service providers try to not only fulfill the functional requirements of web service users, but also satisfy their non-functional conditions in order to survive in the competitive market. A hot research topic is how to configure web services to meet their demand under a dynamic heterogeneous environment. This paper builds a web service configuration net based on Petri nets in order to exhibit web service configuration in a formal way. Then, an optimal algorithm is presented to help choose the best configuration with the highest quality of services (QoS) to meet users' non-functional requirements. Finally, the simulation results and related analysis prove the soundness and correctness of our model and algorithm.