简体   繁体   中英

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.

I am very new to REST and Jersey and so far, I have managed to print "Hello World" on a Tomcat server using NetBeans.

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)

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/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)

How am I supposed to integrate this into my Java code using REST and Jersey?

And how should I insert parameters for the method 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.

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

You also com retrieve the variables in you URL path, like:

@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

I hope that will be useful for you.

If I've misunderstood your question, please let me know!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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