求助:restful接口怎样确定所调用的方法

30 views
Skip to first unread message

Woo

unread,
May 31, 2012, 12:52:24 PM5/31/12
to cxf-zh
大家好:
  初学restful风格的接口,向大家请教问题:怎样确定所调用的方法?

  以下面的情况为例,按我的理解,下面的客户端请求应该由处理方法1处理,但实际上执行是却是由处理方法2处理的。
  请大家多指教,若有相关的说明 “怎样确定所调用的方法” 的文档就更好了。谢谢。

/*------------- 客户端请求 ---------------------*/

@Test
public void testContainerCreate() throws Exception {
HttpClient httpclient = new DefaultHttpClient();

try {
// Create the request
HttpResponse response = null;
HttpPut httpput = new HttpPut("http://localhost:8080/cdmi-
server/TestContainer");
httpput.setHeader("Content-Type", "application/
vnd.org.snia.cdmi.container+json");
httpput.setHeader("X-CDMI-Specification-Version", "1.0");
httpput.setEntity(new StringEntity("{ \"metadata\" :
{ } }"));
response = httpclient.execute(httpput);




/*------------- 处理方法1 ---------------------*/

@PUT
@Path("/{path:.+}")
@Consumes(MediaTypes.CONTAINER)
@Produces(MediaTypes.CONTAINER)
public Response putContainer(
@PathParam("path") String path,
@HeaderParam("X-CDMI-NoClobber") @DefaultValue("false")
String noClobber,
@HeaderParam("X-CDMI-MustExist") @DefaultValue("false")
String mustExist,
byte[] bytes) {
   ...................
...............................
}




/*------------- 处理方法2 ---------------------*/

@PUT
@Path("/{path:.+}")
public Response putDataObject(
@PathParam("path") String path,
@HeaderParam("Content-Type") String contentType,
byte[] bytes) {
....................
......................
}
Reply all
Reply to author
Forward
0 new messages