Java Input and Output Examples

In these examples, the generated API is from the sample AMNU.

Creating Objects Example
Create the API object and input bean, and declare the output bean.
AMNU myAmnu = new AMNU();
GetUserInfo_Input input = new GetUserInfo_Input();
GetUserInfo_Output output;
Create the connection configuration object if you need to provide or override connection or authentication information. If suitable defaults are already provided with properties files, simply use null.
TxConfig txConfig = new TxConfig();
Setting Inputs Example
Set the configuration or authentication values needed.
Set your inputs on the input bean and execute your client operation by calling GetUserInfo(). Name your input fields, setField1 and setField2 and set the inputs as follows:
input.setField1("my input");
input.setField2("more input");
output = myAmnu.GetUserInfo(input, txConfig);
Getting Outputs Example
If your output is not in a table and your output field is named Field1 The following method call retrieves your output:
String output1 = output.getField1();
If you have a repeating element (table) in your client operation named LVL01_DOW_TBL, you can access it from your output bean via a method defined in the bean: To access table data: public List<LVL01_DOW_TBL> getLVL01_DOW_TBL()

The call to get the table is:

List<LVL01_DOW_TBL> myTbl = output.getLVL01_DOW_TBL():

Each element in the list will represent a row in the table. Assuming this table contains multiple rows and has an output field named Field1, you could access it with:

String row2col1 = myTbl.get(2).getField1();
Handling Exceptions Example
All client operations throw the checked TransactionException, which your code will need to either catch or throw. public GetUserInfo_Output GetUserInfo( GetUserInfo_Input input, TxConfig config ) throws TransactionException
TransactionException has several sub-classes that can optionally be caught separately depending on how you'd like to handle different error conditions. This can include connection, authentication, and data errors.
        output = GetUserInfo( input, txConfig );
	catch( ConnectionException ce )
        System.err.println( "Error connecting to host - " + ce.getMessage() );
    catch( AuthenticationException ae )
        System.err.println( "Error authenticating user - " + ae.getMessage() );
    catch( TxRecordException tre )
        System.err.println( "Error processing input or output data - " + tre.getMessage() );
    catch( TransactionException te )
        System.err.println( "Error executing host transaction - " + te.getMessage() );
Related Topics
Bullet Java Sample Application