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

Examples Using Generated Code for Integration Objects


The following code examples use 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.

Siebel Account Business Service Example

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 Account Interface integration object (resident in com.siebel.local.accountinterface).

The code invokes the QueryByExample method of the Siebel Account business service. The parameter to this method is formed from an instance of the Account Interface integration object, 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.accountinterface.Account_InterfaceIO;

import com.siebel.local.accountinterface.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();

Account_InterfaceIO acctIO = new Account_InterfaceIO();

acctIO.addfintObjInst(acctIC);

acctIC.setfName("Ai*");

QueryByExampleInput qbeIn = new QueryByExampleInput();

qbeIn.setfSiebelMessage(acctIO);

// Call QueryByExample

QueryByExampleOutput qbeOut = svc.mQueryByExample(qbeIn);

acctIO = new Account_InterfaceIO(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());

}

}

}

EAI Siebel Adapter Business Service Example

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

import com.siebel.data.SiebelDataBean;

import com.siebel.data.SiebelException;

import com.siebel.local.accountinterface.Account_InterfaceIO;

import com.siebel.local.accountinterface.AccountIC;

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("Account Interface");

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

QueryPageOutput qpOutput = svc.mQueryPage(qpInput);

// Construct the integration object using the QueryPage output

Account_InterfaceIO acctIO =

   new Account_InterfaceIO(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 Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Legal Notices.