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. |
|
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. |
|
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:
|
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:
|
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:
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:
|
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. |
try { 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() ); } |
![]() |
|
![]() |
Java Sample Application |