To invoke a method on most component types, you need to execute the PowerScript statements required to perform these operations:
Use the CreateInstance method to create an instance of the component.
Invoke the method.
You use a different technique to invoke EJB component methods. See “Invoking an EJB component method”.
Example 1 This script instantiates a component on the server and invokes a component method. In this example, the CreateInstance method does not specify a package; therefore, EAServer uses the default package specified in the Application property of the Connection object:
// Global variable:
// connection myconnect
uo_customer iuo_customer
string ls_custid
long ll_rc
ls_custid = Trim(sle_custid.text)
ll_rc = myconnect.CreateInstance(iuo_customer)
if ll_rc <> 0 then
MessageBox("CreateInstance failed", ll_rc)
return 999
end if
if iuo_customer.retrieve_balance(ls_custid) != 1 then
MessageBox("Error", "Retrieve failed!")
end if
Example 2 This script instantiates a component on the server and assigns the object reference to a variable whose datatype is an ancestor of the class for the component. The second argument to the CreateInstance function specifies the class name for the component as well as the EAServer package name:
// Global variable:
// connection myconnect
uo_person lnv_object
string ls_custid
long ll_rc
ls_custid = Trim(sle_custid.text)
ll_rc = myconnect.CreateInstance(lnv_object, &
"PB_pkg_1/uo_customer")
if ll_rc <> 0 then
MessageBox("CreateInstance failed", ll_rc)
return 999
end if
if iuo_customer.retrieve_balance(ls_custid) != 1 then
MessageBox("Error", "Retrieve failed!")
end if
Invoking a local instance
By default, the TransactionServer CreateInstance method
invokes the EAServer name service
to create proxies. Proxies for remote components might be returned
by the name service rather than an instance that is running locally.
To guarantee that a locally installed instance is used, specify
the component name as “local:package/component”,
where package is the package name and component is
the component name. The call fails if the component is not installed
in the same server.