# Customizing Media Types for the Request and Response Messages

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:

- How to Create a Patterned REST Web Service .

- How to Customize Media Types in the Java Source Editor

- How to Customize Media Types in the Annotations View for a Java Class

## How to Customize Media Types in the Java Source Editor

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() { ... }
    }

## How to Customize Media Types in the Annotations View for a Java Class

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

1. Create a POJO.

2. Open the Annotation view.

3. Put cursor on the type declaration, this will orient the available annotations to this location.

4. Add the @Consumer or the @Produces annotation, and specify the value of your annotation.

5. 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.

   Adding Media Type REST Annotations in the Annotations View