Network Function Virtualization (NFV) and Software Defined Networking (SDN) are recently considered as very promising drivers of the evolution of existing middlebox services, which play intrinsic and fundamental roles in today's networks. To address the virtual service deployment issues that caused by introducing NFV or SDN to networks, this paper proposes an optimal solution by combining quantum genetic algorithm with cooperative game theory. Specifically, we first state the concrete content of the service deployment problem and describe the system framework based on the architecture of SDN. Second, for the service location placement sub-problem, an integer linear programming model is built, which aims at minimizing the network transport delay by selecting suitable service locations, and then a heuristic solution is designed based on the improved quantum genetic algorithm. Third, for the service amount placement sub-problem, we apply the rigorous cooperative game-theoretic approach to build the mathematical model, and implement a distributed algorithm corresponding to Nash bargaining solution. Finally, experimental results show that our proposed method can calculate automatically the optimized placement locations, which reduces 30% of the average traffic delay compared to that of the random placement scheme. Meanwhile, the service amount placement approach can achieve the performance that the average metric values of satisfaction degree and fairness index reach above 90%. And evaluation results demonstrate that our proposed mechanism has a comprehensive advantage for network application.