简体   繁体   English

使用Jersey的Java中的REST Web服务

[英]REST web-services in Java using Jersey

What I want to do is to use the 3M Healthcare Data Dictionary Access's web service API to translate a medical term (ie Aortic Aneurysm) in one medical coding language to another using the 3M HDD to map and match the two different languages. 我想做的是使用3M Healthcare Data Dictionary Access的Web服务API使用3M HDD映射和匹配两种不同的语言,将一种医学编码语言中的医学术语(即主动脉瘤)翻译成另一种。

I am very new to REST and Jersey and so far, I have managed to print "Hello World" on a Tomcat server using NetBeans. 我对REST和Jersey非常陌生,到目前为止,我已经设法使用NetBeans在Tomcat服务器上打印“ Hello World”。

It sounds pretty simple but I just need a little push to get a foot in the door. 听起来很简单,但我只需要轻轻推动一下就可以进入大门。


Here are some things I've been struggling with from the getgo: (added another t to http because I don't have access) 这是我一直在getgo中苦苦挣扎的一些事情:(因为我没有访问权限,所以在http中添加了另一个t)

htttp://host:port/api/cts/vb/getSupportedCodeSystems <-- This works and returns an XML with the supported code systems on a browser htttp:// host:port / api / cts / vb / getSupportedCodeSystems <-可以正常工作并在浏览器中返回带有支持的代码系统的XML

htttp://host:port/api/cts/vb/lookupDesignations <-- This doesn't work because this one needs 2 parameters (a codeSystem_ID which is the code for a specific coding language and a Concept Code which is the code for a specific concept ie AANS for Aortic Aneurysm) htttp:// host:port / api / cts / vb / lookupDesignations <-这不起作用,因为这需要2个参数(codeSystem_ID是用于特定编码语言的代码,而Concept Code是用于特定代码语言的代码一个特定的概念,即主动脉瘤的AANS)

How am I supposed to integrate this into my Java code using REST and Jersey? 我应该如何使用REST和Jersey将其集成到Java代码中?

And how should I insert parameters for the method lookupDesignations? 以及如何为方法lookupDesignations插入参数?

Thanks in advance! 提前致谢!

I think that it should work for you: 我认为它应该为您工作:

@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();
}

You can use the Rest Console for Chrome to simulate REST operations to your service. 您可以使用适用于ChromeRest Console对服务进行模拟REST操作。

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

You also com retrieve the variables in you URL path, like: 您还可以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();
}

In this example, you can call the URL: .../lookupDesignations/111/java 在此示例中,您可以调用以下URL:... / lookupDesignations / 111 / java

I hope that will be useful for you. 希望对您有用。

If I've misunderstood your question, please let me know! 如果我误解了您的问题,请告诉我!

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

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