rest
How to return generated ID in RESTful POST?
Return the status code 201 – Created, and put the URL in the Location header. You don’t need to return a body at all.
QueryParam binding with enum in jersey
From the Javadoc, the @QueryParam annotated type must either: Be a primitive type Have a constructor that accepts a single String argument Have a static method named valueOf or fromString that accepts a single String argument (see, for example, Integer.valueOf(String)) Be List<T>, Set<T> or SortedSet<T>, where T satisfies 2 or 3 above. The resulting collection … Read more
Get HttpServletRequest in Jax Rs / Appfuse application?
Try injecting the HttpServletRequest and HttpServletContext directly: @Context private HttpServletRequest servletRequest; @Context private HttpServletContext servletContext;
How to show query parameter options in Django REST Framework – Swagger
New swagger from rest_framework.filters import BaseFilterBackend import coreapi class SimpleFilterBackend(BaseFilterBackend): def get_schema_fields(self, view): return [coreapi.Field( name=”query”, location=’query’, required=False, type=”string” )] class MyViewSet(viewsets.ViewSet): filter_backends = (SimpleFilterBackend,) def list(self, request, *args, **kwargs): # print(request.GET.get(‘query’)) # Use the query param in your view return Response({‘hello’: ‘world’}, status.HTTP_200_OK)
Servlet vs REST
You are confusing two paradigms here: REST is a software architecture “style”; Servlet is a server-side technology. You can, for example, implement REST-like services using Servlets.
FileUpload with JAX-RS
On Server Side you can use something like this @POST @Path(“/fileupload”) //Your Path or URL to call this service @Consumes(MediaType.MULTIPART_FORM_DATA) public Response uploadFile( @DefaultValue(“true”) @FormDataParam(“enabled”) boolean enabled, @FormDataParam(“file”) InputStream uploadedInputStream, @FormDataParam(“file”) FormDataContentDisposition fileDetail) { //Your local disk path where you want to store the file String uploadedFileLocation = “D://uploadedFiles/” + fileDetail.getFileName(); System.out.println(uploadedFileLocation); // save it … Read more
Rest vs. Soap. Has REST a better performance?
Performance is broad topic. If you mean the load of the server, REST has a bit better performance because it bears minimal overhead on top of HTTP. Usually SOAP brings with it a stack of different (generated) handlers and parsers. Anyway, the performance difference itself is not that big, but RESTful service is more easy … Read more