405 error code while calling from Jersey REST clie

2019-06-27 01:57发布

I am requesting for put operation and after request performed I am redirecting to GET service URL.Here, I am facing the issue of 405 HTTP error code. However, same code works for me in the case of POST operation.

Below code is EndPoint:

@PUT
@Produces({ MediaType.APPLICATION_JSON })
public Response put(InputStream objInputStream) {
    // System.out.println("AckService.put()");

    String strOutput = "";
    Status objStatus = Status.OK;
    URI objRedirectionURI = null;

    try {
            this.submitRequest(objInputStream);
            objRedirectionURI = new URI("https://local.test.com:8443/Reply/fetch");
            System.err.println("\n\nredirecting the put request...... to get operation\n\n");
            return Response.seeOther(objRedirectionURI).build();

    } catch (Exception e) {
        e.printStackTrace();
        objStatus = Status.INTERNAL_SERVER_ERROR;
    }


}

Client:

ClientResponse response = null;   
 try {
    response = objWebResource.accept(MediaType.APPLICATION_JSON)
                    .type(MediaType.APPLICATION_JSON)
                    .put(ClientResponse.class, strInputData);

}catch (Exception e) {
    blnIsOk = false;
if(null != e.getMessage())
    lstExceptionMessage.add(e.getMessage());
e.printStackTrace();

}

Please let me know how I can resolve this.

标签: java rest jersey
1条回答
做个烂人
2楼-- · 2019-06-27 02:44

In that question I think you can find the answer: PUT-POST Rest Information

查看更多
登录 后发表回答