Create a
Servlet that wraps the web service and hides all of the nasty details. Then have the result of the Servlet wrapped up on a custom tag. Then, place the custom tag in the theme.
The code becomes easy to manage in the Servlet, complexity is hidden from the custom tag, and the only thing that appears in the theme is the tag itself.
That's a direction. Doesn't need to be a Servlet. Could be just a POJO. But you don't want to pollute a theme any more than a theme is probably already poluted.
Good luck.
-Cameron McKenzie