繁体   English   中英

使用Jersey的Java中的REST Web服务

[英]REST web-services in Java using Jersey

我想做的是使用3M Healthcare Data Dictionary Access的Web服务API使用3M HDD映射和匹配两种不同的语言,将一种医学编码语言中的医学术语(即主动脉瘤)翻译成另一种。

我对REST和Jersey非常陌生,到目前为止,我已经设法使用NetBeans在Tomcat服务器上打印“ Hello World”。

听起来很简单,但我只需要轻轻推动一下就可以进入大门。


这是我一直在getgo中苦苦挣扎的一些事情:(因为我没有访问权限,所以在http中添加了另一个t)

htttp:// host:port / api / cts / vb / getSupportedCodeSystems <-可以正常工作并在浏览器中返回带有支持的代码系统的XML

htttp:// host:port / api / cts / vb / lookupDesignations <-这不起作用,因为这需要2个参数(codeSystem_ID是用于特定编码语言的代码,而Concept Code是用于特定代码语言的代码一个特定的概念,即主动脉瘤的AANS)

我应该如何使用REST和Jersey将其集成到Java代码中?

以及如何为方法lookupDesignations插入参数?

提前致谢!

我认为它应该为您工作:

@Path("/lookupDesignations") // or you complete path
@GET
@Produces(value = MediaType.APPLICATION_XML)
public Response getLookupDesignation(@QueryParam("codeSystemUid") String codeSystemUid, @QueryParam("conceptCode") String conceptCode) {
     // now you have codeSystemUid and conceptCode as String
     // create you entity or list for you entity to return as XML
     return Response.ok().entity(yourEntity).build();
}

您可以使用适用于ChromeRest Console对服务进行模拟REST操作。

示例:... / lookupDesignations?codeSystemUid = 111&conceptCode = java

您还可以com检索URL路径中的变量,例如:

@Path("/lookupDesignations/{codeSystemUid}/{conceptCode}") // or you complete path
@GET
@Produces(value = MediaType.APPLICATION_XML)
public Response getLookupDesignation(@PathParam("codeSystemUid") String codeSystemUid, @PathParam("conceptCode") String conceptCode) {
     // now you have codeSystemUid and conceptCode as String
     // create you entity or list for you entity to return as XML
     return Response.ok().entity(yourEntity).build();
}

在此示例中,您可以调用以下URL:... / lookupDesignations / 111 / java

希望对您有用。

如果我误解了您的问题,请告诉我!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM