Set the base url dynamically



I need to proxy almost directly a service. I know I can create a new http service and set the Base URL. It works as expected. But now I need to set this Base URL dynamically, based on the client parameters. More concretly I need to set the protocol (http/https and the server). What is the recommended way to achieve this? Maybe I need to use other kind of service, but which?