Here’s a class that does something like that. It was developed to call STARTed reports from Nettalk webservices. It creates its own appframe, but maybe you can adapt it to your needs, or extract code from it.