Devices in ubiquitous computing environments are usually embedded, wearable, and handheld, have resource constraints, and are all connected to each other through wireless connections and other computers possibly through fixed network infrastructures, such as the Internet. These devices may form numerous webs of short-range and often low-power mobile ad hoc networks to exchange information. Distributed object computing (DOC) middleware technologies have been successful in promoting high quality and reusable distributed software for enterprise-oriented environments. In order to reap the same benefit in ubiquitous computing environments, it is important to note that the natural interactions among distributed objects in ubiquitous computing environments are quite different due to various factors, such as bandwidth constraints, unpredictable device mobility, network topology change, and context-sensitivity (or situation-awareness) of application objects. Hence, the interactions among distributed objects tend to be more spontaneous and short-lived rather than predictable and long-term. In this paper, a middleware protocol, RKF, to facilitate distributed object-based application software to interact in an ad hoc fashion in ubiquitous computing environments is presented. RKF addresses both spontaneous object discovery and context-sensitive object data exchange. Our experimental results, based on RKF's implementation and evaluation inside the object request broker of our RCSM middleware test bed, indicate that it is lightweight, has good performance, and can be easily used in PDA-like devices.