Create the required connector or connectors in the Application Server. In this particular example, create a connector for the File eWay and another for the Oracle eWay.
Navigate to the Application Server Admin Console at htt://localhost:4848.
Configure the parameters for your connectors under Resources > Connector > Connector Connection Pool and Resources > Connector > Connector Resources.
Launch NetBeans.
From the File menu, select Enterprise > EJB Module.
Create a new EJB project OracleInvokeEJB
Launch the Oracle wizard by right—clicking on the OracleInvokeEJB project and selecting New.
Select Other > SOA > Oracle OTD Wizard.
Click Next.
Enter the Oracle database connection information, and click Next.
Add the database objects (tables, stored procedures, and prepared statements) required for the project, and click OK.
Enter a name for the OTD.
An OTD and a JAR file containing the code corresponding to the above selected database objects are generated. The OTD is generated in the project at the location src/java/otds. The JAR file is added to the project libraries.
Create a JCA-driven MDB by navigating to the File menu, and selecting New Project > Enterprise.
Select File Inbound RAR as the Inbound JCA.
Edit the Inbound File JCA configuration parameters in the following two dialogue windows.
An MDB is created.
In the generated MDB, drag Oracle from the palette to invoke Oracle.
Drag and drop the File JCA onto the onContents() of the MDB, and enter the parameters for the File eWay JCA Adapter declarations.
The Resource JNDI Name should be the same as that declared in the GlassFish Application Server (for example, Resources > Connector > Connector Resources)
Select the Oracle OTD that is generated and click Finish.
Issue a select statement and iterate through the resultset, and write to File.
The resulting Java template is created.
Implement the following Java code:
The following code is the output:
public void onContents(byte[] data, String encoding) throws FaultException, InboundException { try { _invoke_getEmpData(data, encoding); } catch (java.lang.Throwable t) { ectx.setRollbackOnly(); java.util.logging.Logger.getLogger(this.getClass().getName()).log(java.util. logging.Level.WARNING, "exception occurred when invoking method: ", t); } try { _invoke_writeEmpData(data, encoding); } catch (java.lang.Throwable t) { ectx.setRollbackOnly(); java.util.logging.Logger.getLogger(this.getClass().getName()).log(java.util. logging.Level.WARNING, "exception occurred when invoking method: ", t); } } private String _execute_getEmpData(byte[] data, String encoding, otd_emp1.Otd_emp1OTD oraOTD) throws java.lang.Exception { //select all records from EMP table using the method select available //on the OTD oraOTD.getEMP().select(""); //Iterate thru the resultset and write to File. while(oraOTD.getEMP().next()) { enameValues = oraOTD.getEMP().getENAME() + ", " + enameValues; } } private void _execute_writeEmpData(byte[] data, String encoding, com.stc.connector.fileadapter.appconn.FileClientApplication fileOTD) throws java.lang.Exception { fileOTD.setText(new String(data)); fileOTD.write(); } |