SummaryThe software‐as‐a‐service layer of cloud computing has evolved much interest among the researchers in the academic and industry worlds. It is based on service‐oriented architectures and web service (WS) technology, which are used to offer a remotely accessible application. When a single WS is unable to satisfy all the customer's requirements, a WS composition (WSC) method is applied to connect together various available WSs for building distributed application, using discovery, compatibility checking, selection, and deployment steps. This paper has two‐fold contributions: The major one is the proposition of a new algorithm based on minimally unsatisfiable subset formal algorithm to compose WSs. This contribution ensures a faster WSC, which is prominent in an online context. The second contribution is the proposition of a new penalty‐based genetic algorithm to identify near‐optimal solutions whenever an exact one is not identified using our formal algorithm. Indeed, in some cases, many available WSs provide overlapping/identical functionality; in this context, the choice of participated services is given using quality of service. This work proposes a WSC ensuring to find out an exact or a near‐optimal solution according to the user need. A set of experimentations is applied to validate our contributions.