2012-01-02 9 views
9

Utilizzo il server Web Jetty e Jersey per la gestione REST.Server 415 Codice risposta

ho definito:

@POST 
@Path("/sendMessage") 
@Consumes ({MediaType.APPLICATION_XML, MediaType.TEXT_XML}) 
public Response sendMessage(@Context final UriInfo uriInfo) 
{ 
    logger.debug("sendMessage:"); 
    System.out.println("Received POST!"); 
    return Response.status(Response.Status.OK).build(); 

} 

Tuttavia, quando invio una richiesta HTTP, http://localhost:8080/hqsim/sendMessage, il server restituisce un codice 415.

È come se la chiamata non fosse consentita. Come posso risolvere questo errore?

risposta

19

415 indica che il tipo di supporto non è supportato. Il caso più probabile è che manchi l'intestazione Content-Type nella richiesta oppure che non sia corretto. Nel tuo caso deve essere application/xml o text/xml.