Creating RESTful service JAX-RS resources

To create a JAX-RS resource for an Integration Object, in the ZIETrans Projects view:
  1. Expand the project that contains the Integration Object you wish to use, then expand the Source folder and the IntegrationObject folder.
  2. Right-click the Integration Object and select Create RESTful Service Files. The Create RESTful Service Files wizard opens.
  3. On the Specify JAX-RS Resource class name and Integration Object page, in the Name field, specify the name of the JAX-RS resource class to generate in the Source folder. The name must follow generic Java™ class name syntax.
  4. Optionally select whether to Overwrite resources without warnings.
  5. Click Next.
  6. On the Configure JAX-RS Resource class page, in the URI Suffix field, specify a suffix to create the complete URI to use in mapping to your JAX-RS resource. For example, if the host where the ZIETrans RESTful service is installed is www.myHost.com, the ZIETrans project (application) name is myApp, and the URI Suffix is mySuffix, then the resulting URI for the JAX-RS resource is http://www.myHost.com:9080/myApp/rest/mySuffix.
    Note: The combination of URI plus HTTP method must be unique among all of the JAX-RS resources that you define. If not, the JAX-RS runtime picks only one of the resource functions to invoke based on a priority algorithm using the combination of consumes and produces content types (see Customizing RESTful service JAX-RS resource methods).
  7. By default, Enable Swagger is selected. You can disable it if you do not want to include Swagger support. By selecting Copy URI Suffix to Swagger Api Value, you can automatically copy the URI Suffix value to the Swagger Api Value field. To enter a new value, you can uncheck the Copy URI Suffix to Swagger Api Value. The value of this field will be added to respective service as annotation @Api by ZIETrans toolkit.
  8. Click the Add button to add at least one method to the resource class. The Define JAX-RS RESTful Service Method wizard opens.
  9. In the HTTP Method field, from the drop-down list, select the HTTP method (GET, POST, PUT, DELETE) you want to use in combination with the URI to map to this JAX-RS resource method.
  10. Select the Use Integration Object box if you want this method to invoke an Integration Object. Clear the box if you want to generate an empty method without the Integration Object handling code. Do this to create your own customized method.
  11. If you select the Use Integration Object box, from the drop-down list, select the Integration Object you want this method to invoke.
  12. If Enable Swagger is selected in the previous step, then you can enter text in Swagger Api Operation Value field. This field will be ignored if no value is entered by you. The value of this field will be added to respective method as annotation @ApiOperation by ZIETrans toolkit.
    Note: You can access ZIETrans RESTful Swagger description document using the path /<ZIETranscontextroot>/rest/swagger.json
  13. Click Next.
  14. If you selected the Use Integration Object box, the Choose Integration Object properties page displays. Select the input and output properties that you want exposed as parameters for the RESTful Web service. If you wish, you can provide an alias name for the property in the Alias Name field. Use the Select All, Deselect All, and Select Default buttons to help in selecting the properties.
    Note:
    1. Defaults for single Integration Objects and EJB access beans are all macro prompts for input properties and all macro extracts for output properties.
    2. Defaults for chained Integration Objects are all macro prompts plus hPubLinkKey (which is required) for input properties and all macro extracts plus hPubLinkKey (which is required) for output properties.
    3. Defaults for chained EJB access beans are all macro prompts plus hPubLinkKey and hPubAccessHandle (both of which are required) for input properties and all macro extracts plus hPubLinkKey and hPubAccessHandle (both of which are required) for output properties.
    4. To specify that Integration Object connection overrides be exposed to the Web service, you must select the appropriate properties, for example the hPubConnectionOverrides or hPubStartPoolName properties, which are not selected by default. For more information, see Specifying Connection Overrides.
    5. For more information about the use of other Integration Object methods, see Programming with Integration Objects.
  15. Click Next.
  16. On the Configure JAX-RS Resource Method page, defaults are set that reflect the HTTP method and Integration Object you selected. For more information about these method settings and how to customize them, see Customizing RESTful service JAX-RS resource methods. .
  17. Click Finish.
  18. On the Configure JAX-RS Resource class page, in the Methods section, are listed the methods you have added. Use the Add button to add another method, use the Edit button to edit the selected method, and use the Remove button to remove the selected method.
  19. After you click Finish, ZIETrans creates the JAX-RS resource file and stores it in the Source\restfulserviceclasses folder in your project.
  20. In addition, ZIETrans adds the JAX-RS resource to the list of services for the RestServlet servlet to scan for a match. This list is maintained in the WEB-INF/wink-resources.lst file viewable in the Navigator view.
    Note:
    1. ZIETrans creates the WEB-INF/wink-resources.lst file when the first JAX-RS resource is created in a project.
    2. ZIETrans updates the default WAR class loader policy of your ZIETrans application to Single class loader for application.
    3. ZIETrans also adds the JAX-RS facet to the project.
    4. If you create a JAX-RS resource file manually, not using the Create RESTful Service Files wizard, you must update the WEB-INF/wink-resources.lst file to map the JAX-RS resource to the RestServlet servlet.