In this section, we will run the Java client. First, run the client to test outputting just the media type TEXT_PLAIN
. The acceptable media type in the client class must match a MIME media type produced in the resource class. In the JAXRSClient
class, uncomment only the System.out
statement that accepts the TEXT_PLAIN
media type. Uncomment all the resource methods in the HelloWorldResource
class. Then right-click on JAXRSClient.java
and select Run As | Java Application, as shown here:
The resource response gets displayed in the TEXT_PLAIN
media type, as shown here:
An acceptable media type must match a media type produced by the resource class. If a produced MIME media type in the root resource class is not found for an acceptable media type, a com.sun.jersey.api.client.UniformInterfaceException
exception is generated. For example, set an acceptable media type to MediaType.TEXT_XML
by uncommenting the following System.out
statement in the JAXRSClient
class:
System.out...