For this application you need to know what material your sole is made from first. If it is a rubber sole then 'Selleys Shoe Glue':/adhesives/household-adhesive/task-specific/shoe-glue will be ideal.
It is important when using this product, to make sure the surfaces are clean and dry. It will also help to roughen them up a little bit before applying the adhesive. When you apply the product, apply it to both surfaces and wait until they become touch dry then bring them together. Make sure you clamp or put weight on the bonded area for 24 hours, this will ensure you have a strong bond.
Plastic soles are much harder to repair and often will require a professional shoe repairer to fix them.
For more information read 'How to repair a Shoe':/home-improvement/outdoor-renovation/how-to-repair-a-shoe