In a pervasive environment, prior knowledge of tasks is not always possible owing to the characteristic uncertainty of the tasks. Moreover, we may not be able to define any task- template at all that can be modeled as a goal for a service composition process. In this paper, we have modeled a service composition process as an event-handling process in the domain of pervasive computing. We have also shown how event semantics (i.e. the initial and the final states) can define the way events should be handled by a particular pervasive system. The objective is to find the best event- target. This can only be guaranteed if the contexts of the end services producing such event-targets are compatible with the desired event-target contexts. This requires a source service whose context is compatible with that of the event to be handled. Thus, we define Context-Aware Ontology Framework for Events and Services, called CAOFES, which lies in the semantic formalization of the contextual effects of environmental dynamics that can be brought about by services and events. In addition, we present formal definitions of the three different compatibilities: service-to- service compatibility, service-to-event compatibility, and service-to-event target compatibility. The notion of these compatibilities form the essential basis for logically integrating contexts of services participating in a composition process into event-specific contextual boundaries called a Situation Boundary (SB). We have evaluated the performance of compatibility computation of the proposed SB model based on randomly generated service network and contextual information.