Customizing RESTful service JAX-RS resource methods

If you want to customize a ZIETrans RESTful service JAX-RS resource method, for example, to handle content types other than application/xml and application/json, or to define method parameters, follow these steps:
  1. Follow the instructions for Creating RESTful service JAX-RS resources or Updating RESTful service JAX-RS resources.
  2. On the Configure JAX-RS Resource class page, click Add to add a new method or click Edit to edit the highlighted method.
  3. Set the HTTP method, Integration Object, and Integration Object properties as appropriate.
  4. On the Configure JAX-RS Resource Method page, in the Method Name field, specify the Java™ method name.
  5. In the URI Suffix field, add any additions to the path, and add any definitions for URI parameters as PathParam parameters in the format {name}.
  6. In the Return Type field, add or change the Java type returned by this method. The default is restfulserviceclasses.JAX-RS resource class name+ _resource method name+ _Output_Properties.
  7. In the Consumes field are listed the content types (Internet media types, or MIME types) supported for input in the HTTP request body. Add or change the content types of request messages supported. Multiple content types can be specified separated with commas. ZIETrans supports application/xml and application/json as defaults. This is only applicable for HTTP Methods POST or PUT. The HTTP GET and DELETE methods do not have HTTP request bodies and do not support the Consumes field. For these methods, input must instead be supplied as URI parameters with content type application/x-www-form-urlencoded. For more information, see Handling content.
  8. In the Produces field are listed the content types supported for output in the HTTP response body. Add or change the content types of response messages supported. Multiple content types can be specified separated with commas. ZIETrans supports application/xml and application/json as defaults. For more information, see Handling content.
  9. In the Method Parameters fields add or change the input parameters supported by this method. Use the Add, Edit, and Remove buttons to create, modify, and delete the input parameters for this method.
  10. If you create or modify an input parameter, on the Method Parameter page complete the following fields. For more information see the JAX-RS specifications at http://jcp.org/aboutJava/communityprocess/final/jsr311/index.html.
    Parameter Type
    Select from the drop-down one of the following types as defined in the JAX-RS specification:
    • Entity - a non-annotated parameter, for example, a normal Java object, extracted from the request entity body.
    • CookieParam - parameter value is to be extracted from an HTTP cookie.
    • FormParam - parameter value is to be extracted from an HTML form parameter.
    • HeaderParam - parameter value is to be extracted from an HTTP header.
    • MatrixParam - parameter value is to be extracted from a URI matrix parameter.
    • PathParam - parameter value is to be extracted from the request URI path.
    • QueryParam - parameter value is to be extracted from a URI query parameter.
    • Context - parameter value is to be extracted from a Web application context.
    Parameter Name
    Name of the parameter. Used for CookieParam, FormParam, HeaderParam, MatrixParam, PathParam, and QueryParam.
    Default Value
    Default value if the parameter cannot be found. Used for CookieParam, FormParam, HeaderParam, MatrixParam, PathParam, and QueryParam.
    Type
    Input parameter Java type
    Name
    Input parameter name
Note: Each JAX-RS resource must contain at least one method. If the Use Integration Object option is selected, the method contains the ZIETrans RESTful wrapper that maps the input and output parameters for the Integration Object and invokes the Integration Object. By default, ZIETrans maps the parameters to the Integration Object as follows:
  • For HTTP PUT or POST, and the input parameter is mapped as a single entity (Entity).
  • For HTTP GET or DELETE, and the input parameter(s) are mapped as query parameters (QueryParam).
  • The output return type is always an entity (Java object).
If you modify the method parameters as described in this section, ZIETrans does not map the parameters for the Integration Object and does not perform other handling for the modified Java method. In this case, you must edit the JAX-RS resource class file and implement this yourself.