Peel the onions. Clean and wash the leek. Cut both into rings. Preheat oven (electric cooker: 180 °C/circulating air: 160 °C/gas: see manufacturer). Cover baking tray with baking paper.
Fry the ham in oil. Fry onions, leek and 1 teaspoon thyme. Dust with flour and sweat. Add wine, 3⁄4 l water and stock, bring to the boil and simmer for about 10 minutes.
Put bread on the tray. Grate cheese, spread it on top. Bake in the oven for about 5 minutes. Season soup to taste with salt and pepper, arrange it on a plate and put 1 cheese baguette on each.