Java API for calling REST services

Can anyone suggest a better open source Java API for calling REST services? I also wanted to know if the Restlet API supports NTLM authentication.

thanks

+3
source share
4 answers

This is REST - the whole point is that you do not need the API as such, just HttpURLConnection. You should be able to interact with any RESTful service with the underlying Java SDK. You can get fancier with Apache Commons HTTPClient, but this is not necessary.

+7
source

Check out Restlet . It has a good client API.

Usage example:

Request request = new Request(Method.GET, "http://my/rest/api");

Client client = new Client(Protocol.HTTP);

Response response = client.handle(request);

//get response representation and process
+4
source

REST , REST Assured:

// Make a GET request to "/lotto"
String json = get("/lotto").asString()
// Parse the JSON response
List<String> winnderIds = with(json).get("lotto.winners.winnerId");

// Make a POST request to "/shopping"
String xml = post("/shopping").andReturn().body().asString()
// Parse the XML
Node category = with(xml).get("shopping.category[0]");
+1

resteasy , ( , , easymock). :

@Path("/webservice")

public class Web
{

    @GET
    @Path("{web}")
    @ProduceMime("application/xml")
    public String test(@QueryParam("param") String param, @PathParam("web") String web) 
    {
    //  code here
    }
}
  • @Path - " " ( "" components.xml)
  • @GET ""
  • ProduceMime ConsumeMime - ,
  • @QueryParam - URL @PathParam,

, get /webservice/web? param = lalala application/xml

0

Source: https://habr.com/ru/post/1715354/


All Articles