Hi Guys,
I have a class with three functions on the same uritemplate with diffrent
httpmethod (get, post, put) for each. Any time I try to use the post method I
keep getting 405 method not allowed, but the really odd thing is that if I
comment out the functions with the get and put httpmethod, I can use the post
method no problem.
So in the below src, if I comment out getTransaction and processInstructon
funtions, I can use the post methon on uri "/XmlUpdate/blahblah" and hit the
acceptResource function just fine, but the way it it right now if I do the
post to the url "/XmlUpdate/blahblah" I keep getting a 405 responce.
If any one could please point out what I am doing wrong, it would be great as
I am reduced to pulling my hair out at this point.
Thanks
Vishal
###############################################
# java src file
###############################################
import javax.ws.rs.ConsumeMime;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.UriParam;
import javax.ws.rs.UriTemplate;
import javax.ws.rs.core.HttpContext;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
@UriTemplate("/XmlUpdate")
public class MTest {
@HttpMethod("GET")
public Response serviceStatus(@HttpContext HttpHeaders header){
return Response.Builder.representation("serviceStatus", "text/plain")
.header("Etag", "0000000")
.status(200).build();
}
@HttpMethod("POST")
//_at_ConsumeMime("application/x-www-form-urlencoded")
public Response createTransaction(@HttpContext HttpHeaders header,
String xml){
return Response.Builder.representation("createTransaction", "text/plain")
.header("Location", "/")
.header("Etag", "11111")
.status(201).build();
}
@UriTemplate("{transac_id}")
@HttpMethod("POST")
@ConsumeMime("*/*")
public Response acceptResource(@UriParam("transac_id") String transac_id,
@HttpContext HttpHeaders header,
String data){
return Response.Builder.representation(data, "text/plain")
.header("Etag", transac_id)
.header("Location", "/")
.status(201).build();
}
@UriTemplate("{transaction_id}")
@HttpMethod("GET")
public Response getTransactionStatus(@UriParam("transaction_id") String t_id)
{
return Response.Builder.representation("get transaction", "text/plain")
.header("Etag", "222222")
.status(200).build();
}
@UriTemplate("{transaction_id}")
@HttpMethod("PUT")
public Response processInstruction(@UriParam("transaction_id") String t_id,
String xml){
return Response.Builder.representation(xml, "text/xml")
.header("Etag", "3333333")
.status(200).build();
}
}