This paper provides a general framework for service discovery, composition and substitution in a mobile adhoc network scenario. Knowledge representation techniques and approaches are exploited and adapted to the highly flexible and variable ubiquitous computing environment. A polynomial algorithm for composing and orchestrating mobile resources is outlined. Also is presented a simple approach to determine the compatibility among mobile resources and implement a dynamic substitution of services failed or no longer available.