Cognitive Radio (CR) is an innovative wireless sensing technology which can improve efficiency of spectrum usage. Based on CR, Cognitive network (CN) further focus on end-to-end communications for the global optimization and policy enforcement. However, there is a lack of global control channel or middleware for cognitive optimization in CN environment. In this paper, we proposed a Cognitive IP Multimedia Subsystem framework called CogIMS, which consists of benefits from CN and IP multimedia subsystem (IMS). In this framework, the cognitive optimization is modeled as a service over IMS architecture. By adopting the proposed service-oriented framework, the global optimization is simple to achieve under standardized architecture and the computation requirement is reduced from user to core network. Finally, we simulate wireless users who using services to compare CogIMS with CN and IMS. The simulation results show that the proposed CogIMS can achieve the optimization of wireless resource allocation with different network situations.