Customizing the response header

Sometimes you might need to customize the response header of your RESTful service. For example, to handle response headers that use Shift_JIS encoding, you must modify the REST resource class file to change the return type to javax.ws.rs.core.Response and change the content type or custom header. For example, if you want to use Shift_JIS as the default charset in a POST method with a FormParam, perform the following steps:
  1. Specify WebSphere® Application Server encoding as Shift_JIS. For information about how to do this, see the WebSphere Application Server documentation: https://www.ibm.com/docs/was.
  2. Change the return type of the method in the REST resource class to javax.ws.rs.core.Response. For example, change the following code from:
        @POST
        @Consumes({"application/x-www-form-urlencoded"})
        @Produces({"application/xml"})
        public xxx_Output_Properties invoke(@FormParam("id") String id, @FormParam("yyy") String yyy)
        {        
                            :
                            :
          return outputToClient;
        }
    To:
        @POST
        @Consumes({"application/x-www-form-urlencoded"})
        @Produces({"application/xml"})
        public javax.ws.rs.core.Response invoke(@FormParam("id") String id, @FormParam("yyy") String yyy)
        {        
                            :
                            :
          return javax.ws.rs.core.Response.ok(outputToClient, "application/xml;charset=Shift_JIS").build();
        }