Heat oil in a soup pot over medium heat. Cook onion for 5 minutes until softened, then add garlic and cook for 1 minute.
Pour in wine and simmer for 2 to 3 minutes until reduced by about half. Add broth and rosemary and bring to a gentle simmer.
Stir in dry orzo and simmer for 5 minutes, stirring once from the bottom.
Add cannellini beans, escarole, ham and pepper. Simmer gently for 5 to 7 minutes until orzo is tender, escarole has softened and ham reaches 165°F.
Remove rosemary and stir in lemon juice. Taste before adding up to the measured salt, then divide among six bowls and serve promptly.