Nonmanaged Code Sample Using the Siebel Resource Adapter
The following is a code sample using the Siebel Resource Adapter in a nonmanaged environment. The sample performs the same function as the Managed sample; it is a servlet that makes a simple invocation to a business service using the generated JCA code. (For more information about generating code, see About the Siebel Code Generator.)
The JCA ConnectionFactory is created directly. The username, password, connect string, and language are obtained from siebel.properties or set programmatically. Other connection parameters are obtained from the siebel.properties file.
Note: The siebel.properties file must be in the JVM classpath and
must be specified explicitly when the business service instance is
created.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.siebel.integration.jca.cci.notx.SiebelNoTxConnectionFactory;
import com.siebel.service.jca.eaifiletransport.*;
public class BookshelfNonManagedConnectionSample extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
PrintWriter reply = response.getWriter();
try {
EAI_File_TransportBusServAdapter bs = new
EAI_File_TransportBusServAdapter(“siebel.properties�?);
bs.setConnectionFactory(new SiebelNoTxConnectionFactory());
// Username, password, connect string, and language are read from
// siebel.properties, which must be in the classpath of the servlet
// and be specified in the constructor.
// Alternatively, they can be set here programmatically:
// bs.setUserName("USER");
// bs.setPassword("PWD");
// bs.setConnectString("siebel://examplecomputer:2321/siebel/
SCCObjMgr_enu");
ReceiveInput input = new ReceiveInput();
input.setfCharSetConversion("UTF-8");
input.setfFileName("D:\\helloWorld.txt");
ReceiveOutput output = bs.mReceive(input);
reply.println(output.getf_Value_());
}
catch (Exception e) {
reply.println("Exception:" + e.getMessage());
}
}
}