To enable PowerBuilder clients to communicate with EJBs using a proxy server:
Generate a PowerScript proxy class for each EJB session bean that the client application calls. Session beans can use only the datatypes defined in Table 4-2.
Code your PowerBuilder client application to communicate with the proxy server.
Generating PowerScript proxy classes for EJB session beans
For each EJB session bean, generate proxy classes:
Deploy the EJB module to the proxy server.
If you are using the Server Edition of the proxy server and your client application calls only PowerBuilder NVOs (wrapped as EJBs), you can skip this step. When you deploy an NVO, this step is performed automatically.
To deploy an EJB module, where name-prefix is a JNDI name prefix that the application server uses to look up the remote home interfaces in your EJB module. deploy.bat is located in the bin subdirectory of your proxy server installation:
deploy.bat bank.jar -nc:name-prefix
For example, if an EJB called Teller has a JNDI lookup name
of “com.acme.bank/Teller,” the name prefix
must be “com.acme.bank”. If you do not specify
the -nc:name-prefix
option,
an empty name prefix is used.
Use the Application Server Proxy wizard to generate PowerScript proxy classes for the EJB module—see “Generating application server proxy objects”.
A proxy class that is generated using the EJB Client Proxy wizard cannot access the EJB. To rectify, delete the proxy project and the PBL, then generate the proxy class using the Application Server Proxy wizard.
Coding PowerBuilder clients to communicate with proxy servers
In the client application, add the code to establish a connection to the proxy server; for example:
Connection conn conn = create Connection conn.driver = “jaguar” conn.userID = “myUserName” conn.password = myPassword conn.location = “iiop://my-host:2000”; int status status = conn.connectToServer() if status <> 0 then // report error end if
The proxy server passes the values of the connection userID and password properties to your application server. See your application server’s documentation for instructions on configuring user name/password authentication.
If you are using the Client Edition of the proxy server, Sybase recommends that you use a retry loop for establishing a connection, in case the proxy server’s start-up procedure has not completed when you try to connect.
Obtain a reference to call the session bean; for example:
bank_Teller teller status = con.createInstance(teller, “bank/Teller”) if status <> 0 then // report error end if
The name prefix used in the createInstance call is the EJB module name (without the .jar suffix) followed by a “/”; in this example, “bank/”. If the EJB module name contains periods or hyphens, they are replaced with underscores. The name prefix used in the createInstance call need not match the JNDI name-prefix that you specified when you deployed the module.
Call business methods on the session bean; for example:
teller.deposit(“MyAccount”, 1000.0)
For stateful session beans only: remove the session bean. For example:
teller.remove()
Java datatype |
PowerBuilder datatype |
---|---|
Array |
PowerScript Array PowerBuilder methods cannot return an Array datatype. PowerBuilder maps a Java Array return type to a PowerBuilder Structure that contains an array. |
boolean |
Boolean |
byte |
Byte |
byte[] |
Blob |
char |
Char You can use only characters in the ISO 8859-1 character set. If other characters must be propagated via the proxy server, you must use the String datatype. |
double |
Double |
float |
Real |
int |
Long |
java.lang.Boolean |
XDT_BooleanValue |
java.lang.Byte |
XDT_ByteValue |
java.lang.Character |
XDT_CharValue See the note for the char datatype. |
java.lang.Double |
XDT_DoubleValue |
java.lang.Float |
XDT_FloatValue |
java.lang.Integer |
XDT_IntValue |
java.lang.Long |
XDT_LongValue |
java.lang.Short |
XDT_ShortValue |
java.math.BigDecimal |
XDT_DecimalValue |
java.math.BigInteger |
XDT_IntegerValue |
java.sql.Date |
XDT_DateValue |
java.sql.ResultSet |
ResultSet |
java.sql.RowSet |
XDT_DataTable |
java.sql.Time |
XDT_DateValue |
java.sql.Timestamp |
XDT_DateValue |
java.util.Calendar |
XDT_DateTimeValue |
java.util.Date |
XDT_DateTimeValue |
long |
LongLong |
short |
Int |
Serializable class |
PowerScript Structure For any serializable Java class, each non-final non-transient field (private, protected, or public) is mapped to a PowerScript Structure field. Class methods are not mapped. |
Collection types, such as java.util.list, are not supported in this release. Use Java arrays to ensure full interoperability.