¿La API cliente de WebResource de aceptar () no configura correctamente el encabezado MIME?
public static WebResource createWebResource()
{
final ClientConfig cc = new DefaultClientConfig();
final Client c = Client.create(cc);
final WebResource wr = c.resource("http://localhost:19801/wtg_inventory_war/wtg/rest")
.path(inv);
return wr;
}
public void tester()
{
final WebResource wr = JaxrsClientUtil.createWebResource()
.path("wtg-service");
wr.accept(MediaType.APPLICATION_XML);
String response = wr.path("get-services")
.type(MediaType.APPLICATION_XML)
.get(String.class);
System.out.println(response);
}
Lado del servidor
@Path("get-services")
@GET
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response handleFindInventoryServices(
@Context WtgSpringContainer ioc // Spring config for service operations
)
{
System.out.println("Got a service listing request...");
LOGGER.info("Got a service listing request");
Get the app specific data formatted in JAXB XML or JSON...
.
.
.
return Response.ok(msg).build();
}
Independientemente de lo que establece el lado del cliente para un tipo de medio aceptable, ¿vuelve JSON? Usar curl con -HAccept: application / json o application / xml funciona bien. Me gustaría probar mi servidor con ambos sin cambiar el lado del servidor.
¿Algún indicador de por qué no puedo forzar el servidor a XML como mi tipo MIME preferido?