resteasy

create a Jax-RS RESTful service that accepts both POST and GET?

安稳与你 提交于 2019-12-07 02:26:58
问题 I'm converting one of my existing service to become RESTful and I've got the basic things working with RestEasy. Some of my client apps should be able to execute both GET and POST requests to several services. I'm just seeking if there is any easy way around jax-rs to specify that API should accept both GETs and POSTs. Following you can find a test method, let me know if you see any way around without duplicating this in another class with @GET and @QueryParam. @POST @Path("/add") public

ClassNotFound Exception when configuring RestEasy

青春壹個敷衍的年華 提交于 2019-12-07 01:17:45
I'm having trouble while configuring RestEasy with Jboss 5.1GA. I have done everything that the installation manual says to do, Basically downloaded the restEasy zip, copied all the jars inside the lib folder to my war and configured the web.xml like this: <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> <init-param> <param-name>javax.ws.rs.Application</param-name> <param-value>com

Is there a client-side mock framework for RESTEasy?

别等时光非礼了梦想. 提交于 2019-12-06 22:47:14
问题 RESTEasy provides the Server-side Mock Framework for mocking server requests. Is there an equivalent for unit testing the client framework? Is InMemoryClientExecutor intended for this purpose? I'm having trouble finding documentation and examples of how this class should be used. 回答1: Looks like InMemoryClientExecutor may be used for client-side mocking. Looking in the source, it internally uses the same classes as the server-side mock framework, namely, MockHttpRequest and MockHttpResponse .

How to receive a POSTed image in a REST web service

百般思念 提交于 2019-12-06 22:01:41
What is the general approach to exposing a REST based web service that can accept a base64 encoded image. I'm not sure yet if the image will be an InputStream or a ByteArray . I'm using RESTEasy. Can I just map this as a @FormParam ( javax.ws.rs.FormParam )? What is the usual data type for the incoming image? First off, you want to receive the image as an InputStream because they can be quite large. (I have a digital camera that produces a 12 megapixel image. It's not the latest model. The images it produces are quite a few megabytes even when stored as JPEGs. You don't want to get that sort

HTTP 500 Response with Body?

寵の児 提交于 2019-12-06 19:21:13
问题 I have a RESTEasy service that returns a HTTP 500 when a server side error occurs. I manage to attach a body to the HTTP response in order to give more details about the error. So the response that comes out of the service looks something like this HTTP/1.1 500 Internal Server Error Server: Apache-Coyote/1.1 Content-Type: application/xml;charset=ISO-8859-1 Content-Language: en-US Content-Length: 3251 Date: Thu, 14 Oct 2010 23:22:49 GMT Connection: close <?xml version="1.0" encoding="UTF-8"

Android resteasy-mobile sample client

时光毁灭记忆、已成空白 提交于 2019-12-06 16:49:29
问题 I'm new in Android programming, and I need to implement an Android resteasy-mobile client. I need to connect with a remote JAX-RS web service. I've searching arround and I can't find a simple sample client. Can you tell me how can I make an Android resteasy-mobile client? Thank you in advance. 回答1: Finally, I've decided to implement an Android json (Jackson) client whith a Jersey server. Here's my code if someone needs to know how it is: SERVER: package com.sl; import javax.ws.rs.Consumes;

How to set encoding in RESTeasy to UTF-8?

青春壹個敷衍的年華 提交于 2019-12-06 16:09:02
I have a problem with encoding strings in RESTeasy. The problem is that chinese alphabet or any other non-latin characters are not displayed properly. If I try to print them out (or send as response) I get "?????" instead. I believe that default encoding in RESTeasy is us-ascii. Do you know how to change it to UTF-8? Maybe there is another solution to this problem? Here is a short passage from my code: @POST @Path("post") @Consumes(MediaType.MULTIPART_FORM_DATA) public String uploadData(@MultipartForm DataUploadForm uploadForm) { ... //the code below is just for the purpose of presentation

Delete a file after a File response

一笑奈何 提交于 2019-12-06 15:59:09
I want to delete a file after a Resteasy put request. My code: @PUT @Path("/audioconverter") public File audioConverter(@Context HttpServletRequest request, File file, @QueryParam("codec") String codec,.... ... return aFile(); } After the return I want to delete aFile() in the filesystem. How can I do that? Following some advice from above I was able to do the following: File zipDirectory = new File(outputZipFolder); StreamingOutput stream = new StreamingOutput() { @Override public void write(OutputStream output) throws IOException, WebApplicationException { java.nio.file.Path path = Paths.get

Resteasy deploy fails randomly on glassfish 4.1

一世执手 提交于 2019-12-06 15:52:42
I have a problem with my REST-Application using Resteasy. When I deploy the application with this dependencies <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-servlet-initializer</artifactId> <version>3.0.11.Final</version> </dependency> as described here in Chapter 3.5 sometimes the server deploys the application correctly and everything works fine. But sometimes I get Error invoking ServletContainerInitializer org.jboss.resteasy.plugins.servlet.ResteasyServletInitializer java.lang.NullPointerException at org.jboss.resteasy.plugins.servlet.ResteasyServletInitializer

Resteasy 3 integration with Spring 3 not working

非 Y 不嫁゛ 提交于 2019-12-06 15:22:34
I have a project which uses Resteasy and Spring. Before I used the Resteasy version is 2.3.5, which worked fine and no problem. However I recently upgraded the Resteasy version to 3.0.3.Final, when I deployed to jboss it throws some exceptions. Nothing changed just the resteasy version change to 3.0.3.Final. Exceptions: ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-7) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultRestService' defined in "/content/myservice.war/WEB-INF/classes/com