Transports and Interfaces: Siebel Enterprise Application Integration > Integrating with Java > About Running the Java Data Bean >

Examples Using Generated Code for Integration Objects


The following code uses the code generation facilities provided in Siebel Tools. For more information see About the Siebel Code Generator, for both business services and integration objects. By using the code generation facilities, many of the complexities of the Siebel property sets and business service interfaces have been abstracted, providing a standards-based JavaBean interface.

The following is a code sample invoking the QueryByExample method of the Siebel Account business service. In addition to the generated code for Siebel Account (resident in com.siebel.service.jdb.siebelaccount), the sample uses the generated code for the integration object Sample Account (resident in com.siebel.local.sampleaccount).

The code invokes the method QueryByExample of the ASI business service SiebelAccount. The parameter to this method is formed from an instance of the integration object SampleAccount, which serves as the example, essentially specifying a search criterion of all Accounts that start with the letters Ai. The output integration object is converted to a Vector and iterated through to print the names of matching Accounts.

import com.siebel.data.SiebelDataBean;

import com.siebel.data.SiebelException;

import com.siebel.service.jdb.siebelaccount.Siebel_AccountBusServAdapter;

import com.siebel.service.jdb.siebelaccount.QueryByExampleInput;

import com.siebel.service.jdb.siebelaccount.QueryByExampleOutput;

import com.siebel.local.sampleaccount.Sample_AccountIO;

import com.siebel.local.sampleaccount.AccountIC;

public class JDBSiebelAccount {

public static void main(String[] args) throws SiebelException {

Siebel_AccountBusServAdapter svc = new Siebel_AccountBusServAdapter("USER",

"PWD","siebel://mymachine:2321/siebel/SCCObjMgr_enu","enu");

// Create the example-accounts starting with "Ai":

AccountIC acctIC = new AccountIC();

Sample_AccountIO acctIO = new Sample_AccountIO();

acctIO.addfintObjInst(acctIC);

acctIC.setfName("Ai*");

QueryByExampleInput qbeIn = new QueryByExampleInput();

qbeIn.setfSiebelMessage(acctIO);

// Call QueryByExample

QueryByExampleOutput qbeOut = svc.mQueryByExample(qbeIn);

acctIO = new Sample_AccountIO(qbeOut.getfSiebelMessage().toPropertySet());

Vector ioc = acctIO.getfintObjInst();

// print the name of each account returned:

if (!ioc.isEmpty()) {

for(int i=0; i < ioc.size(); i++) {

   acctIC = (AccountIC) ioc.get(i);

   System.out.println(acctIC.getfName());

}

}

}

The following example uses the generated code for the business service EAI Siebel Adapter. An instance is instantiated using the constructor that takes an instance of SiebelDataBean. The QueryPage method is called; its output is actually a SampleAccount integration object, but the object returned is not strongly typed and instead is used to construct a SampleAccount instance. The generated code for SampleAccount is also needed for this example.

import com.siebel.data.SiebelDataBean;

import com.siebel.data.SiebelException;

import com.siebel.local.sampleaccount.AccountIC;

import com.siebel.local.sampleaccount.Sample_AccountIO;

import com.siebel.service.jdb.eaisiebeladapter.EAI_Siebel_AdapterBusServAdapter;

import com.siebel.service.jdb.eaisiebeladapter.QueryPageInput;

import com.siebel.service.jdb.eaisiebeladapter.QueryPageOutput;

public class DataBeanDemo {

public static void main(String[] args) throws SiebelException {

SiebelDataBean m_dataBean = new SiebelDataBean();

String conn = "siebel://mymachine:2321/siebel/SCCObjMgr_enu";

m_dataBean.login(conn, "USER", "PWD", "enu");

// Construct the EAI Siebel Adapter, using the data bean

EAI_Siebel_AdapterBusServAdapter svc =

new EAI_Siebel_AdapterBusServAdapter(m_dataBean);

svc.initialize();

try {

// Set values of the arguments to the QueryPage method.

QueryPageInput qpInput = new QueryPageInput();

qpInput.setfPageSize(Integer.toString(10)); // Return 10 records.

qpInput.setfOutputIntObjectName("Sample Account");

qpInput.setfStartRowNum(Integer.toString(0)); // Start at record 0.

QueryPageOutput qpOutput = svc.mQueryPage(qpInput);

// Construct the integration object using the QueryPage output

Sample_AccountIO acctIO =

   new Sample_AccountIO(qpOutput.getfSiebelMessage().toPropertySet());

// Convert the results to a vector for processing

Vector ioc = acctIO.getfintObjInst();

// Print name of each account

if (!ioc.isEmpty()) {

   for (int i = 0; i < ioc.size(); i++) {

      AccountIC acctIC = ((AccountIC) ioc.get(i));

      System.out.println(acctIC.getfName());

   }

}

} catch (SiebelException e) {}

finally {

m_dataBean.logoff();

}

}

}

Transports and Interfaces: Siebel Enterprise Application Integration