resteasy

Extract specific node of JSON response in RESTEasy Client

怎甘沉沦 提交于 2019-12-25 09:05:11
问题 I'm retrieving a JSON string from an API using a RESTEasy client. The JSON payload looks something like this: { "foo1" : "", "foo2" : "", "_bar" : { "items" : [ { "id" : 1 , "name" : "foo", "foo" : "bar" }, { "id" : 2 , "name" : "foo", "foo" : "bar" }, { "id" : 3 , "name" : "foo", "foo" : "bar" }, { "id" : 4 , "name" : "foo", "foo" : "bar" } ] } } Now I'd like to extract only the items node for object mapping. What is the best way to intercept the JSON response body and modify it to have

Rest PHP receiving values from android side

二次信任 提交于 2019-12-25 04:36:20
问题 REST File:Rest.inc.php <?php class REST { public $_allow = array(); public $_content_type = "application/json"; public $_request = array(); private $_method = ""; private $_code = 200; public function __construct(){ $this->inputs(); } public function get_referer(){ return $_SERVER['HTTP_REFERER']; } public function response($data,$status){ $this->_code = ($status)?$status:200; $this->set_headers(); echo $data; exit; } private function get_status_message(){ $status = array( 100 => 'Continue',

How to use the same ContainerRequestFilter for multiple projects?

谁说我不能喝 提交于 2019-12-25 03:39:10
问题 I have two projects A and B in which B has dependency on A. So all the classes of A are available to B. Now, I've defined a ContainerRequestFilter for intercepting some information from request. This is getting invoked if I call the end points of project A. But it's not getting invoked if I call end points of project B. Obviously, the context roots of project A and project B are different. Example: http://localhost:8080/projecta/..... http://localhost:8080/projectb/..... Both the projects are

Restful site broke after upgrading resteasy-jaxrs to the lastest version

社会主义新天地 提交于 2019-12-25 02:32:12
问题 I'm going through this tutorial example on RestEasy: http://www.mkyong.com/webservices/jax-rs/resteasy-hello-world-example/ I downloaded their code and made modification so that I can deploy it to tomcat 7 and java 1.7. If I leave the pom.xml as specified by the site, <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxrs</artifactId> <version>2.2.1.GA</version> </dependency> then everything appears to be fine and can be accessed through: http://localhost:8080

RestEasy - upload file (multipart/form-data) with cyrillic name

…衆ロ難τιáo~ 提交于 2019-12-25 01:52:45
问题 When I upload a file to the server, everything is fine. But if the name of the file contains cyrillic characters, on the server that filename appears with question marks. I don't set any character encoding when I send request to the server. I know that if you don't put any character encoding in the header when you make request, the default character encoding that RestEasy puts is us-ascii. I tried a couple of ways to change it: With new String(filename.getBytes("US-ASCII"), "UTF-8") - didn't

NoSuchMethodError javax.validation.Validator.forExecutables() but the Junit works

岁酱吖の 提交于 2019-12-24 20:16:06
问题 Why do I get this exception NoSuchMethodError javax.validation.Validator.forExecutables() when I run the application and the following method is called but the exception is never thrown if I call the method from a JUnit test, it executes perfectly. I'm using Spring AOP 3.2.4 + AspectJ and Hibernate Validator 5.0.1. It complains that it can't find the forExecutables method. Thanks @Before("execution(* com.sadc.missioncontrol.api.client.models.workRequest.MaintainTimesheet.getPublicHolidays(..)

Quarkus RestEasy ws.rs Resource, CompletionStage exception handling

纵然是瞬间 提交于 2019-12-24 18:41:32
问题 If I defined my rest-easy Resource this this way: @GET @Path("/stuff") @Produces(MediaType.APPLICATION_JSON) public Response getStuff() { final Single<Stuff> stuffSingle = stuffService.getStuffAsync(); return Response.ok().entity(stuffSingle.blockingGet()).build(); } And exception happens somewhere at getStuffAsync() method. I could go with ExceptionMapper to delegate it to handle exceptions. @Provider public class MyExceptionMapper implements ExceptionMapper<Exception> { .. And it works - it

405 Method Not Allowed is coming as Http Status 500 in RestEasy

喜夏-厌秋 提交于 2019-12-24 16:53:20
问题 Currently developing a Restful Service using RestEasy Framework. Facing a trouble when it comes to handling 405 - javax.ws.rs.NotAllowedException: RESTEASY003650: No resource method found for POST, return 405 with Allow header. Already written a ErrorHandler for NotAllowedException using ExceptionMapper and registered the provider in root application which extends javax.ws.rs.core.Application . But still it returns 500 error and sets the Http Status to 500 instead of 405. Whereas other

Accessing HttpSession in PreProcessInterceptor

血红的双手。 提交于 2019-12-24 15:35:33
问题 Is it possible to access/create the HttpSession in the preProcess method of a PreProcessInterceptor ? (RestEasy 2.3.4) 回答1: You can access the HttpSession by injecting the HttpServletRequest using the @Context annotation and then getting the session from the request like so: @Context private HttpServletRequest servletRequest; @Override public ServerResponse preProcess(HttpRequest request, ResourceMethod method) throws Failure, WebApplicationException { HttpSession session = servletRequest

Why doesn't this work - jsonp and REST Easy?

两盒软妹~` 提交于 2019-12-24 14:38:03
问题 JS code <html> <head> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script> $.getJSON("http://localhost:8080/gbsshop/rest/auth/test/xyz?callback=?", function (data) { alert("52"); }); </script> </head> </html> REST Easy method @GET @POST @Path("/test/{param}") @Produces({MediaType.APPLICATION_JSON }) public String returnMessage(@PathParam("param") String msg) { System.out.println("~~~~~~~~~~~~~"+msg+"~~~~~~~~~~~~"); return "HEllo "+msg; } I see that the server gets the