Step 1. Have a cleric cast Miracle to learn which plane the soul is entrapped on.
Step 2. Learn what deity is most likely tied to that plane in such a way as to perhaps be able to find the entrapped soul.
Step 3. Go to that plane, likely through Plane Shift (if you can acquire the proper kind of key linked to that plane) or possibly through Wish or simply looking for a portal somewhere, on the material, ethereal, astral, or shadow plane.
Step 4. Use Commune or Contact Other Plane to ask a suitable deific being if they know the location of the entrapped soul. Or use Gate or Greater Planar Ally to bring in a solar, pit fiend, balor, ultraloth, arcanaloth, formian queen, rakshasa, coutl, djinni, efreeti, dao, marid, or the like, as appropriate to the plane you and the entrapped soul are on, and ask them if they can find it or find someone who can find it. Be prepared to pay copiously in either goods, souls, or favors as necessary to seal the deal. You might try gating in a marut inevitable, but it'd be tricky convincing the marut that bringing back your friend will serve the marut's purpose of preventing and punishing the avoidance of death (your friend's not dead, just trapped, and will never die so long as he remains so.....). :\
Step 5. Proceed with whatever plan is set forth by the divine being you have gotten your information from. Provided you can trust the source!
As an alternative, just find some way to contact an appropriate sort of deity directly, without the limited nature of a Commune spell, and ask them where exactly to find the entrapped soul and free it. Or go to Sigil, City of Doors, and ask around. You might find someone there who can do the seemingly-impossible and locate or free your friend.