Choosing an Attachmate API

Deciding which interface to use is a process that depends on various inputs. Are you writing applications in Java, or are you writing native Win32 applications? Are you using Web services? What about J2EE? With which type of application server are you integrating? These decisions are frequently driven by the needs of your customers.

Before deciding which interface is appropriate for your situation, you'll need to create one or more tasks and be familiar with your client application requirements.

Available Interfaces

APIs are provided for the following development environments, applications, and component technologies:

Development Environment Remarks
Java Several different Java-based APIs for running tasks are defined, including custom step functionality and native access to handle difficult navigation problems.
Native Win32 Two COM interfaces are provided for developers who prefer native Win32 environments (such as ASPs, VisualBasic, or C#).
Web services You can choose between three Web service application servers with which to integrate: BEA WebLogic (v. 6.1 and 7.0), Microsoft .NET, and Apache Axis.
J2EE Connector Architecture Two J2EE Connector Architecture (JCA)-compliant resource adapters are provided: JCA Adapter for WebLogic Integration and J2EE Session EJBs, which are packaged in an enterprise application.

Choosing a Java Interface

There are currently four Java interfaces available to you:

Note A stateless task is one that does not maintain context information about previous executions; stateful tasks can pick up where the last task left off.
 

These samples were all generated from a project called Test. Test contains a single task called Task, which has a single input and output called, respectively, Input and Output. The generated task file is also provided.

Generated interface objects, and the APIs they define, are custom tailored for one particular project. The samples will not compile and run against other projects or tasks.

Java Interfaces Description Characteristics
IConnectorAccess (ICA) An XML-based API used by all of the Synapta Services Builder, and is typically a bit more flexible than the other APIs.
  • Fields and methods are defined by the IConnectorAccess interface.
  • Supports stateful tasks (chaining).
  • Supports Native Access — NativeAccessConnector (NAC) is based on the IConnectorAccess XML-based API.
ITask A Java bean-based API that is also used by all of the Synapta Services Builder. ITask has a smaller footprint than ICA, and is typically slightly faster than IConnectorAccess because no XML parsing is needed.
  • Fields and methods are defined by the ITask interface.
  • Task-specific methods — a set method for each defined task output and get and set methods for each defined task input.
  • Supports stateful tasks (chaining).
  • Supports Native Access — NativeAccessBean (NAB) extends ITask, adding NativeAccess methods by implementing INativeAccessEx.
  • Task beans provide a listener interface for monitoring task execution.
Service Beans Efficient, lightweight Java beans that work well in J2EE environments.
  • Task-specific methods and helper classes for task inputs and task outputs.
  • Supports stateless tasks, and as such, do not support either task chaining or Native Access.
  • Multiple tasks included in one bean.
INativeAccessEx INativeAccess defines an API through which data from the screen may be accessed generically using XML. INativeAccessEx is a derived interface used by the ScreenNativeAccessEx task bean to access a session. The INativeAccessEx interface supplies the screen view as a series of properties.
  • Has exceptional navigation handling.
  • Get or set methods used to access field and screen information.
  • Supported by the ITask and IConnectorAccess APIs.

See the Javadocs for details about the Attachmate Java interfaces.

Solving Advanced Navigation Issues

Note Writing your own custom steps, from within Task Builder, provides a server-side solution to navigation problems that are either too difficult or impossible for a task, recorded using the standard design-time workflow, to solve. When you use custom steps and the server-side API you no longer have to rely on screen native access to deal with advanced navigation issues.

See Using Custom Steps for information and instructions on using this solution for challenging workflows.

What is Native Access and When Should I Use It?

Screen native access is a client-side task, with pre-defined inputs and outputs, that provides you with direct access to the Runtime Service's internal view of the host screen. Using native access you can programmatically interact with the screen to solve problems that cannot be handled with simple tasks. In addition to getting field and screen attributes, you can query for information in the navigation map (NavMap) used to build the connection without having to create host specific beans.

All the field and screen attribute information plus commands have been normalized to generic constants defined in INativeAccessConstants. Native access support is provided via the ITask and IConnectorAccess APIs.

Native Access Interfaces

Description

INativeAccessEx This ITask derived interface is used by the ScreenNativeAccessEx task bean to access a session.
IConnectorAccess This XML-based interface uses the special native access task document to access a session.

The INativeAccessEx interface supplies the screen view as a series of properties and get or set methods are used to access both field and screen information.

When should I use native access?

There are two reasons for using native access:

  1. Provide access to host screen field data, which supplies programmers with not only a snapshot of the current host screen but the ability to interact with it dynamically by modifying fields and sending AID keys.

  2. Native access can be a "backdoor" to the Runtime Service's navigation engine. This is a last resort scenario and should be used only when problems cannot be solved using standard techniques. For example, gathering data from an asymmetric table where fields are either non-uniform or the number of columns is dynamic could be done using native access.
Note Will native access work in a COM environment?  You can use native access via the COM bridge with XML-based IConnectorAccess. The ITask implementation of native access is Java only, but the IConnectorAccess implementation can be used in native Win32 environments because the COM bridge is just an IConnectorAccess wrapper.

What native access does not do

Native access does not supply "presentation" features such as field validation, field text formatting, field tab ordering, or OIA lines. Native access only supports commands or data that goes all the way to the host. Presentation features are only supported on the workstation (renderer) or controller and need to be supplied by the user application.

for detailed technical information on native access, as well as complete Javadocs for all the Attachmate Java interfaces, see Using Screen Native Access, Overview.

Points to remember

  1. IConnectorAccess is XML-based, maintains state, supporting both task chaining and native access.

  2. ITask is Java-bean based, maintains state, supporting task chaining and native access.

  3. Service beans are stateless, and do not support task chaining or native access. Multiple tasks can be encapsulated in a single service bean in contrast to the task beans where one task is contained in a single bean.

Choosing a Native Win32 Interface

  

Both the COM Interface and the Proxy Service enable native Win32 implementations to interact with the Java-based Services Builder.

These samples were all generated from a project called Test. Test contains a single task called Task, which has a single input and output called, respectively, Input and Output. The generated task file is also provided.

Generated interface objects, and the APIs they define, are custom tailored for one particular project. The samples will not compile and run against other projects or tasks.

See the COM Interface API Reference and Proxy Service API Reference for detailed information on both these interfaces.

Native Win32 Interfaces Description Characteristics
COM Interface The COM interface is a native Win32 version of the IConnectorAccess API. It is a wrapper that loads the Java Virtual Machine (JVM) and uses Java Native Interface (JNI) to interact with Java-based IConnectorAccess implementations. When you use this interface you get one JVM per client process.

—Provides one JVM per client process, and while using the Proxy Service, provides one JVM per machine.

—Executes stateful tasks in process.

ScreenConnectorProxy Service The ScreenConnectorProxy Service is a Windows service that maintains a single instance of the JVM for executing stateless tasks. It exposes a simple DCOM API through which client applications can run tasks in the shared VM.

—Supports stateless tasks, and as such, does not support either task chaining or Native Access.

—When calling the Execute(...) method, the value
com.attachmate.connector.screen.ScreenConnectorAccessImpl
must be provided as the first parameter. No other value will work.

For more information, see Building Applications Using Native Win32 Technologies.

Points to remember

When deciding between the two native interfaces there are a few things to keep in mind:

  1. The ScreenConnectorProxy Service provides a simplified API and executes stateless tasks out of process. It does not support task chaining or native access.

  2. The COM interface maintains state and supports task chaining and native access. The COM interface is a native wrapper for ICA and executes stateful tasks in process.

  3. To use the ScreenConnectorProxy Service, when calling the method Execute(...), you need to provide the value "com.attachmate.connector.screen.ScreenConnectorAccessImpl" as the first parameter. No other value will work.

  4. Using the COM interface you get one JVM per process, while using the Proxy Service, you get one JVM per machine.


Choosing a Web Service

Attachmate Synapta Services Builder for Screens provides support for Web services. Web services, which are generated by Task Builders, can be used in a variety of development environments to expose host access tasks as Web services and then be made available as resources to other applications and application components.

  

These samples are all simple console applications demonstrating how to execute a Web service via the three types of application servers supported by Attachmate.

These samples were all generated from a project called Test. The project contains a single task called Task. The task has a single input and output called respectively, Input and Output. The generated task file is also provided.

Generated interface objects, and the APIs they define, are custom tailored for one particular project. The samples will not compile and run against other projects or tasks.

Application Server Description
BEA WebLogic 7.0 A J2EE-compliant, Web service platform. Attachmate Synapta Services Builder provide a JCA resource adapter for WebLogic, which uses BEA WebLogic Integration (WLI) extensions. J2EE session EJB support is provided for BEA WebLogic 8.1 through the Synapta Services Builder management console.
.NET Microsoft's .NET framework provides a Web service framework for Windows environments.
Apache Axis A free cross-platform application server.

What Web service you decide to use is based on your application server.

Points to remember

  1. Installers may be generated for your Web services platform.

  2. The Web service platform creates a Web Services Description Language (WSDL) file, which your development environment can use to interact with the Web service.

  3. Web services only support "stateless" tasks, meaning they do not support task chaining or native access.

  4. When Web services are generated they are custom-tailored for one particular project or task so the APIs will vary. However, a Web service API will always define the following in some manner:

There are installation and deployment instructions for each supported application server in this Product Guide, under Using Tasks in Your Applications.


Building Applications using Attachmate's J2EE Supported Architecture

Before the J2EE Connector Architecture (JCA) was introduced, there was no standardized method to integrate enterprise systems with legacy data. However, the advent of JCA and Attachmate's J2EE-compliant architecture made it possible to access host data and integrate with supported application servers, including BEA WebLogic, IBM WebSphere, Sun Microsystem SunONE, and Oracle AS.

The J2EE connector code sample illustrates how to use a J2EE connector defined by the task file. This sample assumes that you have deployed a J2EE connector to your application server with the task file and placed it in the Java Naming and Directory Interface (JNDI) with the name, "Sample."

The session EJB code sample illustrates how to use a stateful J2EE session EJB defined for the task file. This sample assumes that you have deployed a J2EE Session EJB application to your application server with a JNDI name of AccountQueryStatefulEJB.

Building Applications using J2EE Session EJBs

Session EJBs are efficient, lightweight, Java beans that work well in J2EE environments. As a part of an enterprise application, along with the J2EE connectors, they are deployed as an EAR file to your selected application server. Characteristics are:

Note A stateless task is one that does not maintain context information about previous executions; stateful tasks can pick up where the last task left off.

Example:

In this example, you set task inputs, execute the task, and get task outputs.

	//create screen inputs object, define screen outputs variable 
        AccountQueryStateful.AccountLookupTaskInput.ScreenInputs si = new AccountQueryStateful.AccountLookupTaskInput.ScreenInputs();
        AccountQueryStateful.AccountLookupTaskOutput.ScreenOutputs so = null;

        // set task input(s)
        si.setAccountNumber(AccountNumber);

        // execute task with inputs and collect outputs
        so = ejb.AccountLookupTask(si);

        // get task output(s)
        Balance = so.getBalance();    

Building Applications using J2EE Connectors

The Synapta Services Builder provide two JCA-compliant resource adapters.

Attachmate JCA adapter for WebLogic uses Web services generated in the task builder component and BEA WebLogic Integration (WLI) extensions.

Attachmate J2EE connectors, as a part of a packaged session EJB, implement the JCA Common Client Interface (CCI), and are managed and deployed as an enterprise application to selected application servers through your Synapta Services Builder management component.

Accessing Data with the J2EE Connectors

The Attachmate J2EE connector implementation returns Record objects, which mimic a hierarchical XML structure and use combinations of MappedRecords and IndexedRecords. (Input or output data is referred to as a Record.)

Record Type Description
Mapped
  • Map directly to elements of complexType.
  • Any element that is complexType and has maxOccurs greater than 1 will be represented as an IndexedRecord with each entry containing a MappedRecord. All elements of simpleType will map to that type in Java (only string types are supported in the Synapta Services Builder at this time).
  • Each child element is a key into the MappedRecord.
  • Can contain maps to other MappedRecords, IndexedRecords, or a Java string.
Indexed
  • Map directly to any element with maxOccurs greater than 1.
  • Any element that is complexType and has maxOccurs greater than 1 will be represented as an IndexedRecord with each entry containing a MappedRecord. All elements of simpleType will map to that type in Java (only string types are supported in the Synapta Services Builder at this time).
  • Can contain entries to MappedRecords or Java strings.

The RecordFactory is part of the J2EE connector architecture. To obtain a particular Record from the RecordFactory, you must ask for it by name. The format of the name is:

TASK/MODE[/CHILD]

where TASK is the name of the task you are going to execute, MODE is either input or output, and CHILD is an optional child record.

For example, if you have a task named "test" and you want to get the input record, use the name "test/input". If the root element of the task "test input" has a child element, "bar," that is complexType, and therefore a MappedRecord, you access that Record as "test/input/bar".

Note The actual name of the root element is never specified and is assumed to be the first top-level element in the task schema.

For more information about implementing J2EE solutions, see How to Deploy and Manage J2EE Session Beans.

Related Topics
Bullet Using Tasks in Your Applications, Overview
Bullet Configuring Your Development Environment
  Attachmate