Smart cities are becoming a reality. Various aspects of modern cities are being automated and integrated with information and communication technologies to achieve higher functionality, optimized resources utilization, and management, and improved quality of life for the residents. Smart cities rely heavily on utilizing various software, hardware, and communication technologies to improve the operations in areas, such as healthcare, transportation, energy, education, logistics, and many others, while reducing costs and resources consumption. One of the promising technologies to support such efforts is the Cloud of Things (CoT). CoT provides a platform for linking the cyber parts of a smart city that are executed on the cloud with the physical parts of the smart city, including residents, vehicles, power grids, buildings, water networks, hospitals, and other resources. Another useful technology is Fog Computing, which extends the traditional Cloud Computing paradigm to the edge of the network to enable localized and real-time support for operating-enhanced smart city services. However, proper integration and efficient utilization of CoT and Fog Computing is not an easy task. This paper discusses how the service-oriented middleware (SOM) approach can help resolve some of the challenges of developing and operating smart city services using CoT and Fog Computing. We propose an SOM called SmartCityWare for effective integration and utilization of CoT and Fog Computing. SmartCityWare abstracts services and components involved in smart city applications as services accessible through the service-oriented model. This enhances integration and allows for flexible inclusion and utilization of the various services needed in a smart city application. In addition, we discuss the implementation and experimental issues of SmartCityWare and demonstrate its use through examples of smart city applications.