resteasy

RestEasy Client Authentication and HTTP Put with Marshalling

♀尐吖头ヾ 提交于 2019-12-05 19:27:13
I want to test my REST-Service using the RestEasy Client Framework. In my application I am using Basic Authentication. According to the RestEasy documentation I am using the org.apache.http.impl.client.DefaultHttpClient to set the Credentials for Authentication. For an HTTP-GET Request this works fine, I am authorized and I get the result Response which I wanted. But what if I want to make a HTTP-Post/HTTP-Put with an Java Object (in XML) in the HTTP-Body of the Request? Is there a way to automatically marshall the Java Object into the HTTP-Body when I am using the org.apache.http.impl.client

application/* Content-Type and charset attributes

别说谁变了你拦得住时间么 提交于 2019-12-05 16:14:36
The RFC-2616 states in 3.7.1: When no explicit charset parameter is provided by the sender, media subtypes of the "text" type are defined to have a default charset value of "ISO-8859-1" when received via HTTP. This is why I usually use e.g. text/plain; charset=utf-8 as Content-Type Header. What about MediaTypes of type application ? I often see und use headers like Content-Type: application/xml; charset=UTF-8 . RESTeasy 2.3.7 then forces the client to also send the charset parameter in the Accept header. Otherwise it will answer with a 406 . RESTeasy 3.0.6 seems to be quite more tolearant here

How to set HTTP header in RESTEasy 3.0 client framework (with ResteasyClientBuilder and ResteasyWebTarget)?

浪子不回头ぞ 提交于 2019-12-05 13:54:15
I'm trying to figure out how to set HTTP headers similar to what was explained here: How to set HTTP header in RESTEasy client framework? , or here RESTEasy client framework authentication credentials However, I want to use RESTeasy 3.0 functionality (ResteasyClientBuilder and ResteasyWebtarget) and not the deprecated ProxyFactory, as explained here: What is the substitute for Resteasy ProxyFactory class And just to clarify, I also do not want to set the header(s) on every request / don't want them to be passed to the client, I'd like them to be set on ResteasyClientBuilder/ResteasyWebtarget

RESTEasy - javax.ws.rs.NotFoundException: Could not find resource for full path

我的梦境 提交于 2019-12-05 13:10:53
I've tried to implement a REST service with RESTEasy in a GWT project, but when I get into the respective URI the application returns: Grave: failed to execute javax.ws.rs.NotFoundException: Could not find resource for full path: http://127.0.0.1:8888/api/matches at org.jboss.resteasy.core.registry.ClassNode.match(ClassNode.java:73) at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48) at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:444) at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher

Dynamically change RESTEasy service return type

瘦欲@ 提交于 2019-12-05 12:39:49
Am I able to change the value of @Produces annotation parameter in my RESTEasy services?? The task I'm given is to integrate multiple format reporting to an existing reporting system. So changing the @Produces annotation parameter dynamically would help me a lot. Thanks in advance! Make your method return a Response object and try something like this; int status = 200; String type = MediaType.APPLICATION_XML; String response = "<hello>world</hello>"; return Response.status(status).type(type).entity(response).build(); I think the type in the response will override what you annotated, but I

JAX-RS (Resteasy 3.5.0.Final) + Wildfly 12 + Java 9 + maven = 404 not found, but JAX-RS (Resteasy 3.5.0.Final) + Wildfly 12 + Java 8 + maven works

妖精的绣舞 提交于 2019-12-05 11:59:38
I have got a simple Hello World example JAX-RS project. Really simple and stupid. Just minimal configuration, which I intend to enhance in future, just imagine something like this with : https://robferguson.org/blog/2016/12/02/getting-started-with-resteasy/ . Well, my problem is, that when I set the Java version to "1.9", I always receive a "404 not found" error. But when I change it back to 1.8, mvn clean install and deploy, it works fine. The java version is the only delta, which makes it working or not working. How to make it work with java 9? I do use maven 3.5 and jdk 9.0.4. works fine:

RESTEasy doesn't recognize custom message body writer

瘦欲@ 提交于 2019-12-05 11:43:49
My MessageBodyWriter @Provider @Produces("text/csv") public class CSVMessageBodyWriter implements MessageBodyWriter<JaxbList> public static final String CONTENT_DISPOSITION_HEADER = "Content-Disposition"; //$NON-NLS-1$ private final static HeaderDelegate<ContentDispositionHeader> header = RuntimeDelegate.getInstance().createHeaderDelegate(ContentDispositionHeader.class); public long getSize(JaxbList t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { return -1; } public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType

Resteasy generally enable GZIP

我怕爱的太早我们不能终老 提交于 2019-12-05 10:37:05
I have a RestEasy + Java EE application. When I add @GZIP to a component class, the server-answer is gzipped, if the client sends "accepts:gzip" Is there a way to generally enable gzip for all components? I don't like to add the annotation to every class. I'm using RestEasy JAX-RS 3.0.1 No, there is no way with annotations to enable gzip for all resources. If you wanted to forego adding the annotation to every class you could create a servlet filter that looks at the incoming headers and gzips the response on the way out. if you are implementing your API behind an interface, so all your

Getting “java.lang.ClassNotFoundException: javax.servlet.http.HttpServlet” in Eclipse + jboss 5.1.0

删除回忆录丶 提交于 2019-12-05 09:45:33
I'm trying to get a simple RestEasy project to work in Eclipse (with Jboss Tools) and Jboss 5.1.0. To get going, I've created a simple Dynamic Web Project. In the project, I've include the following in WEB-INF/web.xml: <context-param> <param-name>resteasy.scan</param-name> <param-value>true</param-value> </context-param> <listener> <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class> </listener> <servlet> <servlet-name>Resteasy</servlet-name> <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> </servlet>

RestEasy Post Process Interceptor chain not traversed when response created by ExceptionMapper

大兔子大兔子 提交于 2019-12-05 09:26:10
I am using RestEasy to build up my Restful web services. I have implemented ExceptionMappers to prepare specific exception responses. I have also implemented MessageBodyWriterInterceptors and a couple of PostProcessorInterceptors. Issue: All works fine when any resource does not throw any exception. My implementation works as expected. All the post processor interceptors and the message body writer interceptors are called. But when an exception is thrown from any of the resource methods, the registered ExceptionMappers are called and it is creating the response. But in this case the post