Software AG Products 10.7 | Integrating On-Premises and Cloud Applications | Service Development | Building Java Services | Generating Java Code from Service Input and Output Parameters
 
Generating Java Code from Service Input and Output Parameters
 
Example of Java Code Generated from Service Signature
If you know the set of input and output parameters that a Java service will use before you start coding it, you can declare the service’s input/output parameters first and generate Java code from it. The generated code obtains the specified input values from the service’s input signature and assigns them to variables in your service. It also puts the set of output values into the output signature.
You do not have to generate code for all the input and output parameters. You can choose to generate code for only the input parameters, only the output parameters, or you can select one or more input/output parameters for which to generate code.
When Designer generates code from the service input/output parameters, it puts the code on the clipboard. From there, you can paste it into the Source tab of your service, or if you are building a Java service in your own IDE, you can paste it into the service in your IDE. After pasting the generated code, you can modify it as necessary.
*To generate starter code from a Java service’s input/output parameters
1. Open the Java service by double clicking it in the Package Navigator view.
2. Select the Input/Output tab and define the inputs and outputs for the service if they are not already specified. For more information, see About the Service Signature.
3. If you want to generate code for a subset of the input/output parameters, on the Input/Output tab select the parameters for which you want to generate code. To select more than one variable, press the CTRL key as you select parameters.
4. Right click in the editor to view the context menu, and select Generate Code.
5. In the Code Generation window, select For implementing this service and click Next.
6. For Specification, select the Input and/or Output check boxes to reflect the parameters for which you want to generate code.
7. For Which Fields? select one of the following:
*All Fields if you want to generate code for all of the parameters identified by your Specification selection.
*Selected Fields if you want to generate code for only the parameters you selected before starting the code generation.
8. Click Finish. Designer generates code and places it on the clipboard.
9. Select the Source tab. Alternatively, if you are building a Java service using your own IDE, open the Java service in your IDE.
10. Paste the contents of the clipboard into your source code.