Majority of the existing approaches to service composition, including the widely popular planning based techniques, are not able to automatically compose practical workflows that include complex repetitive behaviors (loops), taking into account possibility of failures and nondeterminism of web service execution results. In this work, we present a learning based approach for composing task specific workflows. We present an approach for learning task specific web service compositions from a very small number of observations (one or more) of example service execution sequences (traces) that solve a given goal. The workflows learned by this approach generalize to the tasks justified by the observed execution trace. The generalization captures the repetitive executions of service sequences, conditional branching executions, and repetitions and branching resulting from failures. We evaluate the approach on a complex web services application involving arbitrary number of repetitive execution...