First describe the UNO-URL, which describes where the acceptor is located.
Then create a bootsrap object and with this bootstrap object create a
component context object. Next get the Servicemanager of the component
context, which is an interface, and use it to create a connection service
(UnoUrlResolver). Finally tell the connection service to connect to the
previously prepared UNO-URL.
For further details see http://wi.wu-wien.ac.at/rgf/diplomarbeiten/BakkStuff/2008/200809_Frysak/200809_Frysak_Automating_OOo_ooRexx_Nutshells.pdf.
-- identify target program
unourl = "uno:socket,host=localhost,port=2002;urp;StarOffice.ServiceManager"
-- create bootstrap object
bootstrap = uno.wrap(.bsf~new("{%see com.sun.star.comp.helper.Bootstrap}"))
-- create the Component Context
x_ComponentContext = bootstrap~createInitialComponentContext(.nil)
-- get the UNO Service Manager
s_UnoServiceManager = x_ComponentContext~getServiceManager()
-- create an UNO connection interface
urlresolver = "{%see com.sun.star.bridge.UnoUrlResolver}"
s_UnoUrlResolver = s_UnoServiceManager~createInstanceWithContext(urlresolver, x_ComponentContext)
x_UnoUrlResolver = s_UnoUrlResolver~{%see com.sun.star.bridge.XUnoUrlResolver%XUnoUrlResolver}
-- connect to Open Office and retrieve "StarOffice.ServiceManager" service
s_ServiceManager = x_UnoUrlResolver~resolve(unourl)
::requires UNO.CLS