いらっしゃいませ actually literally means "Come in!" in a formal way, and it is used to get customers. You often hear it (or the short, more... friendly or pushy or manly? version いらっしゃい) when you pass by some stalls at a festival, or when you enter a shop or restaurant etc.
ようこそ means "welcome (to somewhere)" in a bit wider sense. If you want to make it more formal, you can say for example ようこそおこしくださいました. I mean, it's not bad to use plain ようこそ to strangers or guests either. In some places where they have their own dialectal variant, they might use it instead of ようこそ, for example おこしやす in Kyoto or めんそーれ in Okinawa. These may also be used in shops etc. when a customer comes in.