resteasy

Ajax request with JAX-RS/RESTEasy implementing CORS

喜夏-厌秋 提交于 2019-12-04 08:38:54
I have two servers (Apache and JBoss AS7) and I need to provide access to all http methods to a client. All these request must be sent via ajax. Example of the client code: $.ajax({ type: "get", url: "http://localhost:9080/myproject/services/mobile/list", crossDomain: true, cache: false, dataType: "json", success: function(response) { console.log(response); }, error: function (jqXHR, textStatus, errorThrown) { console.log(textStatus); console.log(jqXHR.responseText); console.log(errorThrown); } }); In JBoss AS7 I'm using RESTEasy, implementing CORS as follows: @Path("/mobile") @Provider

RestEasy client framework file upload

谁都会走 提交于 2019-12-04 08:26:48
问题 Does anyone know how to create the RestEasy client side calls to upload a file using the following two interface signatures? I'm not finding any information at all. I know how to do it using the HttpClient but I'd like to use the client proxy to keep it consistent. @POST @Path("/upload") @Consumes("multipart/form-data") public void uploadFile(MultipartFormDataInput input); @POST @Path("/upload2") @Consumes("multipart/form-data") public void uploadFile2(@MultipartForm FileUploadForm form); Any

RestEASY and Jackson incompatibility - NoSuchMethodException

无人久伴 提交于 2019-12-04 05:04:34
问题 I migrated my project from JBoss AS 7.2 to WildFly 8.0 and after some time of updating versions I can't figure out, how to solve RestEASY and Jackson incompatibility. In JBoss AS 7.2 I used RestEASY 3.0.6.Final and Jackson 2.2.1 and they worked like a charm. But now, with WildFly's Jackson 2.3 , there is an incompatibility. Server throws an NoSuchMethodError exception: 13:56:27,049 ERROR [io.undertow.request] (default task-3) UT005023: Exception handling request to /iqpp/applicants/: java

RESTEasy + Jackson: how to exclude fields in the response?

╄→尐↘猪︶ㄣ 提交于 2019-12-04 04:01:19
I'm migrating my Java web application from servlet-based to JAX-RS. Since I'm using Jboss I'll also use (by default) RESTEasy. In my servlets I use Jackson to serialize/deserialize JSON; Jackson allows me to filter programatically the inclusion/exclusion of fields, for example: ObjectMapper mapper = new ObjectMapper().setVisibility(JsonMethod.FIELD, Visibility.ANY); String[] ignorableFieldNames = { "id", "name" }; FilterProvider filters = new SimpleFilterProvider(). addFilter("f123",SimpleBeanPropertyFilter.serializeAllExcept(ignorableFieldNames)); mapper.filteredWriter(filters)

Custom Jackson serializer of resteasy client

好久不见. 提交于 2019-12-04 03:42:09
问题 Is it possible to register a custom Jackson JSON serializer for the resteasy client? I've tried to do something like: ResteasyClient client = new ResteasyClientBuilder() .register(new CustomSerializer()) .build(); But it didn't work. Any ideas? 回答1: You can only register JAX-RS components like Providers or Features. You need to register an Provider which carries an ObjectMapper which carries an Module with your serializer registered. ResteasyJacksonProvider resteasyJacksonProvider = new

Changing Default JSON Time Format with RESTEasy 3.x

非 Y 不嫁゛ 提交于 2019-12-04 03:30:58
I am using RESTEasy to implement a REST Service using JSON serialization. Currently, Dates are getting serialized to milliseconds since 1970. To improve compatibility, I would like to get my dates into one of two formats; milliseconds + timezone offset or ISO 8061. It seems that RESTEasy used to use Jettison for JSON serialization, but from what I've been reading they've switch to Jackson ... all of this has made googling for help pretty hit or miss. From what I can tell, I need to implement a ContextResolver along the lines of: public class JacksonConfig impelments ContextResolver

RestEasy @Path Question with regular expression

a 夏天 提交于 2019-12-04 02:35:21
问题 Is it possible to define path with optional path variables. like the uri below: /app/make/{make}/model/{model}/year/{year}/mileage/{mileage}/fuelType/{fuelType}/maxPrice/{maxprice}/transmission/{transmission}/engineSize/{engineSize} URI may be composed of any 0 or more combinations of the parameters? Is there a way to tell resteasy that all those paths are optional? cheers. 回答1: Why bother using path segments? If they are optional parameters then it can't be a real hierarchy so why not just

Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: text/html - in Resteasy

Deadly 提交于 2019-12-04 00:09:39
I am developing RESTEasy Example. In this example I am using all latest dependencies and deploying om tomcat 8.x version. I can successfully deploy the application but when I am launching the url: http://localhost:8080/RESTfulExample/rest/restwebservice/list , I see following errors are coming. Please guide what is going wrong here. org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: text/html at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:66) at

CORS angular js + restEasy on POST

强颜欢笑 提交于 2019-12-03 21:49:21
I'm doing some POST requests from my angular js app to my RESTful API implemented using RestEasy . The case is that I need CORS so I added a servlet filter with this code: public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletResponse response = (HttpServletResponse) res; response.addHeader("Access-Control-Allow-Origin", "*"); response.addHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); response.addHeader("Access-Control-Max-Age", "3600"); response.addHeader("Access-Control-Allow-Headers",

How to generate WADL file?

非 Y 不嫁゛ 提交于 2019-12-03 21:30:56
I wrote RESTful web service using RESTeasy implementation and turn EJB into JSON. And now I'm on the way of development client side. I'm using Netbeans. How I can generate WADL file? And after I would generated client stub without any problem. Please, could you suggest me how I can do this? Or maybe you know different easy way. Thanks a lot! Artem Just FYI if you are trying to create a RESTful system, then generating client proxies using WADL will eliminate a significant number of the benefits REST provides. However, if you are using the term REST as a way to describe a Http API (HAPI) service