Advances in Internet and software technology play increasing roles in creating work environments and online services that impact our everyday living. Web service computing paradigm has revolutionized how these software applications can be developed rapidly and reliably by employing available services available in standard forms across the web. Automatic composition of web services is necessary and challenging when there are a huge growing number of available web services but no single service offers the desired function. This paper presents an approach to automatically combining published web services to meet the application requirements using as few services as possible. Our approach is based on heuristic algorithms that incorporate semantics of services from their ontology into identifying valid executable services in the composition structure. The paper describes the approach and evaluates its performance on public service repositories. Our experimental results show correct optimized solutions 100% of the time, with a reduction in the average running time, compared to champion of Web service challenge' 06 competition, of 60.2% over 31 composition problems.