resteasy

What scope do JAX-RS 2 filters have?

♀尐吖头ヾ 提交于 2019-12-21 21:32:44
问题 I am using RestEasy 3.0.2 which is one of the first JAX-RS 2 implementations and run my application within a Tomcat 7. I also make use of injection in my application via WELD which is integrated with RestEasy via its CDI adaptor. Everything works fine so far. Now, I wrote an implementation of a ContainerRequestFilter to perform authentication of incoming requests before they hit a resource. The JAX-RS standard says that injection is possible for every resource and every other JAX-RS component

Can Resteasy look into parameter's type for JAX-RS methods?

只愿长相守 提交于 2019-12-21 20:24:21
问题 We were using Resteasy 3.0.9 for our JAX-RS webservices, and recently switched to 3.0.19, where we started to see a lot of RESTEASY002142: Multiple resource methods match request warnings. For example, we have methods like: @Path("/{id}") public String getSome(UUID id) @Path("/{id}") public String getSome(int id) I'm not sure how it worked in 3.0.9, probably, we just were very lucky as Resteasy seems to select first method from all candidates (and 3.0.19 sorts candidate methods). One solution

Ajax request with JAX-RS/RESTEasy implementing CORS

烂漫一生 提交于 2019-12-21 17:47:59
问题 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);

Is it possible to reuse Java trusted certificates for javax.ws.rs (Resteasy implementation)?

左心房为你撑大大i 提交于 2019-12-21 09:35:02
问题 Suppose we need to trust a self-signed SSL certificate. As an example, let's use https://self-signed.badssl.com/. Since the signer is not a "proper" authority, Java doesn't trust it and refuses to connect to that server. However, after $ cd $JAVA_HOME/jre/lib/security $ keytool -import -trustcacerts -alias ... -file ... -keystore cacerts and restart of the application, the following code works: new URL ("https://self-signed.badssl.com/").openConnection ().getResponseCode () and returns 200

Timeout webservice call from client side

二次信任 提交于 2019-12-21 09:06:11
问题 I'm calling a webservice using RestEasy Client. One requirement is to abort/timeout the call if it runs for more that 5 seconds. How would I achieve this with RestEasy Client? I have only seen server side timeout, i.e. the Rest Easy websevice will timeout the request if it's not fulfilled within a certain time. 回答1: A RESTEasy client typically uses Apache HttpClient to handle the network conversation. You can override the HttpClient properties with your own custom timeout parameters:

Resteasy multipart/data-form file upload on GAE

假装没事ソ 提交于 2019-12-21 04:28:20
问题 I'm trying to use resteasy 2.0.1.GA to upload a form with a file in it into GAE application, using the method advised at How do I do a multipart/form file upload with jax-rs? Index.html <form action="/rest/upload" method="post" enctype="multipart/form-data"> <input type="text" name="name" /> <input type="file" name="file" /> <input type="submit" /> </form> Rest.java @Path("") public class Rest { @POST @Path("/rest/upload") @Consumes("multipart/form-data") public String postContent(

Set JSON provider at RESTEasy on JBoss 7.1.1

老子叫甜甜 提交于 2019-12-21 04:23:37
问题 How could I set JSON provider for RestEasy at JBoss 7.1.1? RestEasy documentation says: RESTEasy allows you to marshall JAXB annotated POJOs to and from JSON. This provider wraps the Jettison JSON library to accomplish this. But I found that it seems that on JBoss 7.1.1 Resteasy uses Jackson provider because @XmlTransient on my class field was ignored, but @JsonIgnore was processed. How can I tell to Resteasy to use Jettison instead of Jackson? On Jboss I found both providers. 回答1: if you

Set response headers not using filter - RESTeasy

谁说胖子不能爱 提交于 2019-12-21 04:21:28
问题 I am trying to set a header value in a response from a RESTful endpoint using RESTeasy. I know that I can read header parameters using @HeaderParam but I want to change the value of that header parameter for the response. How can I do this without using a filter? 回答1: RESTEasy can inject HttpResponse which enables you to set header parameters. @Path("/") public class MyService { @Context org.jboss.resteasy.spi.HttpResponse response; @GET @Path("/") public void setHeader(){ response

Set response headers not using filter - RESTeasy

北城以北 提交于 2019-12-21 04:21:16
问题 I am trying to set a header value in a response from a RESTful endpoint using RESTeasy. I know that I can read header parameters using @HeaderParam but I want to change the value of that header parameter for the response. How can I do this without using a filter? 回答1: RESTEasy can inject HttpResponse which enables you to set header parameters. @Path("/") public class MyService { @Context org.jboss.resteasy.spi.HttpResponse response; @GET @Path("/") public void setHeader(){ response

Return File From Resteasy Server

一世执手 提交于 2019-12-21 04:13:38
问题 Hi, I wanted to return a file from a resteasy server. For this purpose, I have a link at the client side which is calling a rest service with ajax. I want to return the file in the rest service. I tried these two blocks of code, but both didn't work as I wanted them to. @POST @Path("/exportContacts") public Response exportContacts(@Context HttpServletRequest request, @QueryParam("alt") String alt) throws IOException { String sb = "Sedat BaSAR"; byte[] outputByte = sb.getBytes(); return