Add the javax.ws.rs.Consumes or javax.ws.rs.Produces annotation at the class or method level of the resource to customize the media type of the request and response messages, respectively. More than one media type can be declared in each case.
With OEPE, you can customize message types for request and response using one of the following options:
Customize media types for your REST web service by adding the @Produces or @Consumes annotation at the class or method level of the resource. Then you can input the media types values for your produces and consumes attributes, as shown in Example: Customizing the Media Types for the Response using @Produces Annotation.
Customizing the Media Types for the Response using @Produces Annotation
package samples.produces;
import javax.ws.rs.Produces;
import javax.ws.rs.Path;
@Path("/myResource")
@Produces("text/plain")
public class GetDogTreats {
@GET
public String doGetAsPlainText() { ... }
@GET
@Produces("text/html")
public String doGetAsHtml() { ... }
}
Use the Annotations view to add your media type annotations and properties to your Java classes.
To create REST web services using the Annotation view
Create a POJO.
Open the Annotation view.
Put cursor on the type declaration, this will orient the available annotations to this location.
Add the @Consumer or the @Produces annotation, and specify the value of your annotation.
Specify the resource value of your annotation. Choose from the available values for that annotation. For example @Produces("text/plain"), as shown in Figure: Adding Media Type REST Annotations in the Annotations View.