Tag: resteasy

用什么代替org.jboss.resteasy.client.ClientRequest?

我刚刚发现org.jboss.resteasy.client.ClientRequest已被弃用,这使我在Google上找到的有关如何使用RESTEasy客户端的所有内容无效。 Javadoc没有说明使用什么。 谷歌也是沉默的。 我现在已经恢复到2.3.5 ,但无论如何都会对答案感兴趣,以及如何在不问别人知道的情况下如何找到答案 – 是否有资源提供我可以看到的信息?

如何在RESTEasy客户端框架中设置HTTP标头?

RESTEasy(一个JAX-RS实现)有一个很好的客户端框架 ,例如: RegisterBuiltin.register(ResteasyProviderFactory.getInstance()); SimpleClient client = ProxyFactory.create(SimpleClient.class, “http://localhost:8081”); client.putBasic(“hello world”); 你如何设置HTTP标头? 澄清: jkeeler提出的解决方案是一种很好的方法,但我想在ProxyFactory级别设置HTTP标头,我不想将标头传递给客户端对象。 有任何想法吗?

如何使用RestEasy将JSON转换为POJO列表

我必须将我们的j2ee应用程序与REST Web服务集成。 我想使用JBoss的RestEasy JAX-RS实现。 webservice以JSON格式返回一个数组。 我有这段代码: Client client = ClientBuilder.newClient(); WebTarget target = client.target(“http://myservices.com/schemes/all”); Response response = target.request().get(); 我可以使用RestEasy将此“响应”对象映射到List吗? 谢谢

JAX-RS NoMessageBodyWriterFoundFailure

我的jax-rs应用程序的方法: @GET @Produces (MediaType.APPLICATION_JSON) public List getDocumentList(@HeaderParam(“Range”) String headerRange) { int [] range = getRangeFromHeader(headerRange); return facade.listByRange(range); } 好好工作。 但如果修改: @GET @Produces(MediaType.APPLICATION_JSON) public Response getDocumentList(@HeaderParam(“Range”) String headerRange) { int[] range = getRangeFromHeader(headerRange); return Response.ok( facade.listByRange(range)) .header(“Content-Range”, getContentRangeStr(range)).build(); } 我收到一个错误 …NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: application/json… 服务器Jboss […]

Maven shade + resteasy可以找到内容类型的作家

我有一个项目可以正常使用maven托管依赖项。 但我要求将我的jar文件作为一个。 为此,我使用maven-shade插件( http://maven.apache.org/plugins/maven-shade-plugin/ )。 所有类文件都正确导出但是当我尝试运行我的应用程序时,我得到一个错误: 可以找到内容类型multipart / form-data类型的writer:org.jboss.reasteasy.plugins.provider.multipart.MultipartFormDataOutput 任何帮助都会很棒,谢谢。 注意:我遇到类似spring的问题,其主要原因是配置文件。 许多jar文件包含具有相同名称的configuraiton文件。 所有配置文件都尝试覆盖其他配置文件。 将该文件与maven-shade配置合并后问题得以解决。

RestEASY和Jackson不兼容 – NoSuchMethodException

我将我的项目从JBoss AS 7.2迁移到WildFly 8.0 ,经过一段时间的更新后,我无法弄清楚,如何解决RestEASY和Jackson不兼容问题。 在JBoss AS 7.2中,我使用了RestEASY 3.0.6.Final和Jackson 2.2.1 ,他们的工作就像一个魅力。 但现在,对于WildFly的 Jackson 2.3 ,存在不兼容性。 服务器抛出NoSuchMethodErrorexception: 13:56:27,049 ERROR [io.undertow.request] (default task-3) UT005023: Exception handling request to /iqpp/applicants/: java.lang.NoSuchMethodError: org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider._configForWriting(Lcom/fasterxml/jackson/databind/ObjectMapper;[Ljava/lang/annotation/Annotation;)Lcom/fasterxml/jackson/jaxrs/json/JsonEndpointConfig; at org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider.writeTo(ResteasyJackson2Provider.java:137) [resteasy-jackson2-provider-3.0.6.Final.jar:] at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.writeTo(AbstractWriterInterceptorContext.java:129) [resteasy-jaxrs-3.0.6.Final.jar:] at org.jboss.resteasy.core.interception.ServerWriterInterceptorContext.writeTo(ServerWriterInterceptorContext.java:62) [resteasy-jaxrs-3.0.6.Final.jar:] at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:118) [resteasy-jaxrs-3.0.6.Final.jar:] at org.jboss.resteasy.security.doseta.DigitalSigningInterceptor.aroundWriteTo(DigitalSigningInterceptor.java:143) [resteasy-crypto-3.0.6.Final.jar:] at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:122) [resteasy-jaxrs-3.0.6.Final.jar:] at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.aroundWriteTo(GZIPEncodingInterceptor.java:100) [resteasy-jaxrs-3.0.6.Final.jar:] at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:122) [resteasy-jaxrs-3.0.6.Final.jar:] at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:99) […]

RESTEasy – 动态添加资源类

使用RESTEasy,我实现了Application的子类,以提供单例资源列表。 有没有办法在以后动态添加另一个单身? 我没有找到一种方法从API文档中做到这一点。

如何使用RESTeasy从multipart / form-data请求获取text / xml为UTF-8?

谢谢你的回答,但使用InputStream而不是使用getBody(…)也行不通。 下面的代码返回与原始post中的结果相同的结果。 final InputStream inStream = fileUploadInput.getFormDataPart(searchedInput, InputStream.class, null); // get bytes final byte[] inBytes = new byte[1024]; final ByteArrayOutputStream outBytes = new ByteArrayOutputStream(inBytes.length); int length = 0; while((length = inStream.read(inBytes)) >= 0) { outBytes.write(inBytes, 0, length); } final byte[] rawInput = outBytes.toByteArray(); // get Encoding final String asciiInput = new String(rawInput, ASCII); final String […]

jboss使用@Context注入Resteasy参数

我正在使用jboss 7.1和resteasy进行基于令牌的身份validation。 我正在使用PreProcessInterceptor来拦截请求,获取令牌,从令牌中检索用户,然后根据放置在方法上的自定义注释检查用户角色。 我现在要做的是将User注入方法,如下所示。 @Path(“/doStuffWithUser”) @GET @Requires(“ADMIN”) // custom annotation public Response doStuffWithUser(@Context User user); 我知道这与这个问题非常接近,我尝试在链接的github示例中添加了不同的解决方案,但是我找不到从PreProcessInterceptor中注入用户的方法。 谢谢

RestEasy:org.codehaus.jackson.map.JsonMappingException:无法从START_OBJECT标记(..)中反序列化java.util.ArrayList的实例

我有一个rest端点,它返回List 。 我试图测试这个rest端点为 @Test public void testGetAllVariablesWithoutQueryParamPass() throws Exception { final ClientRequest clientCreateRequest = new ClientRequest(“http://localhost:9090/variables”); final MultivaluedMap formParameters = clientCreateRequest.getFormParameters(); final String name = “testGetAllVariablesWithoutQueryParamPass”; formParameters.putSingle(“name”, name); formParameters.putSingle(“type”, “String”); formParameters.putSingle(“units”, “units”); formParameters.putSingle(“description”, “description”); formParameters.putSingle(“core”, “true”); final GenericType<List> typeToken = new GenericType<List>() { }; final ClientResponse<List> clientCreateResponse = clientCreateRequest.post(typeToken); assertEquals(201, clientCreateResponse.getStatus()); final List variables = […]