resteasy

JaxB unmarshal custom xml

↘锁芯ラ 提交于 2020-01-06 02:28:07
问题 I'm currently attempting to unmarshal some existing XML into a few classes I have created by hand. Problem is, I always get an error that tells me, JaxB expects a weather element but finds a weather element. (?) javax.xml.bind.UnmarshalException: unexpected element (uri:"http://www.aws.com/aws", local:"weather"). Expected elements are <{}api>,<{}location>,<{}weather> I tried with and without "aws:" in the elements' name. Here's my weather class: @XmlRootElement(name = "aws:weather") public

JAX-RS Request interceptor missing dependencies

你说的曾经没有我的故事 提交于 2020-01-04 06:28:59
问题 Here's the intereceptor code, which is the only difference in whether I get these errors. package com.lm.infrastructure; import java.io.IOException; import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.container.ContainerRequestFilter; import javax.ws.rs.container.PreMatching; import javax.ws.rs.ext.Provider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Provider @PreMatching class RequestLogger implements ContainerRequestFilter { @Override public void filter(

How do I @Inject a CDI @ApplicationScoped bean into a @RequestScoped JAX-RS bean?

為{幸葍}努か 提交于 2020-01-03 13:35:34
问题 I've added the @ApplicationScoped CDI annotation to a simple bean: @ApplicationScoped public class History { And tried to then @Inject this into a JAX-RS (resteasy) bean: @RequestScoped @Path("/history") public class HistoryAPI { @Inject private History history; But history remains null. I've got a beans.xml file in WEB-INF. I've tried a lot of variations on this theme, but while the app server (Wildfly) acknowledges it's starting with CDI I can't get the injection to work. Any ideas what I"m

How do I @Inject a CDI @ApplicationScoped bean into a @RequestScoped JAX-RS bean?

怎甘沉沦 提交于 2020-01-03 13:34:16
问题 I've added the @ApplicationScoped CDI annotation to a simple bean: @ApplicationScoped public class History { And tried to then @Inject this into a JAX-RS (resteasy) bean: @RequestScoped @Path("/history") public class HistoryAPI { @Inject private History history; But history remains null. I've got a beans.xml file in WEB-INF. I've tried a lot of variations on this theme, but while the app server (Wildfly) acknowledges it's starting with CDI I can't get the injection to work. Any ideas what I"m

Why are error pages ignored in RESTEasy web service running on Tomcat?

百般思念 提交于 2020-01-03 05:09:07
问题 I'm developing a REST-ful web service using RESTEasy deployed on Tomcat. I've configured an error page which takes the exception's message and generates an XML based on it when any exception occurs during the request. This works fine for any application generated exceptions. However, if client sends an invalid XML which cannot be unmarshalled correctly, an javax.xml.bind.UnmarshalException is thrown and Tomcat's default error page is used instead of mine. I have configured my error page to

Parameters order with and @XmlType(propOrder) and Resteasy jackson

筅森魡賤 提交于 2020-01-03 02:46:21
问题 I produce json using resteasy. Everything works fine but... I can't order the parameters of my generated json: In my serialized class, I have the following anotations: @XmlRootElement @XmlType(propOrder={"foo1", "foo2", "foo3"}) in my generated json, i get: {"foo2":"bar2","foo1":"bar1","foo3":""} There is the following dependency in my pom.xml <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jackson-provider</artifactId> <version>2.2.0.GA</version> </dependency> any

How to generate wadl file for resteasy in jboss

孤者浪人 提交于 2020-01-02 07:06:24
问题 I want to generate a wadl file for my project which is using resteasy + Jboss 6.4 + Maven. There are many examples given for jersey but not for resteasy does anyone used it for resteasy 回答1: Resteasy since 3.0.14.Final do support WADL generation. You need to add resteasy-wadl to your dependency manager (e.g. maven): <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-wadl</artifactId> <version>3.0.19.Final</version> </dependency> then declare a new servlet endpoint in your

Web开发之RSET API

扶醉桌前 提交于 2020-01-02 01:35:08
REST介绍   如果要说什么是REST的话,那最好先从Web(万维网)说起。   什么是Web呢?读者可以查看维基百科的词条( http://zh.wikipedia.org/zh-cn/Web ),具体的我就不多说了。总之,Web是我们在互联网上最常用的服务,甚至在某些人的心中,互联网就是Web。当然,Web只是互联网的一部分而已,只是大家用的最多而已,我们访问的所有网站都是基于Web。   那么,Web和REST之间究竟有什么关系呢?我们接下来将聊聊组成Web的几大基础技术, URI (统一资源标识符,用来标识资源)、 HTTP (超文本传输/转移协议,用来操作资源)、 Hypertext (超文本,用来描述资源的内容与状态,我们可以用HTML、XML、JSON或者自定义格式的文本来描述任何一个资源)。   那我们再来看看什么是REST呢?其实REST并不是一种新兴的技术语言,也不是什么新的技术框架。准确来说说REST只是一种概念、风格或者约束,是回归HTTP本身的建议。   REST是由Roy Thomas Fieding在他的博士论文《Architectural Styles and the Design of Network-based Software Architectures》(《架构风格与基于网络的软件架构设计》)中提出的一种架构思想。Roy

REST服务开发实战

可紊 提交于 2020-01-02 01:34:39
   转自: http://kb.cnblogs.com/page/91827/ REST介绍   如果要说什么是REST的话,那最好先从Web(万维网)说起。   什么是Web呢?读者可以查看维基百科的词条( http://zh.wikipedia.org/zh-cn/Web ),具体的我就不多说了。总之,Web是我们在互联网上最常用的服务,甚至在某些人的心中,互联网就是Web。当然,Web只是互联网的一部分而已,只是大家用的最多而已,我们访问的所有网站都是基于Web。   那么,Web和REST之间究竟有什么关系呢?我们接下来将聊聊组成Web的几大基础技术, URI (统一资源标识符,用来标识资源)、 HTTP (超文本传输/转移协议,用来操作资源)、 Hypertext (超文本,用来描述资源的内容与状态,我们可以用HTML、XML、JSON或者自定义格式的文本来描述任何一个资源)。   那我们再来看看什么是REST呢?其实REST并不是一种新兴的技术语言,也不是什么新的技术框架。准确来说说REST只是一种概念、风格或者约束,是回归HTTP本身的建议。   REST是由Roy Thomas Fieding在他的博士论文《Architectural Styles and the Design of Network-based Software Architectures》(

Specific MessageBodyWriter for field

天涯浪子 提交于 2020-01-01 05:44:14
问题 Say I have a data class in a JAX-RS 1 environment (RestEasy 2 with the Jackson provider) like this: class Foo { int id; String name; Bar bar; ... } with Bar being: class Bar { int one; String two; } Now I want to have Bar serialized in a special way (perhaps depending on the media type that was requested (or depending the phase of the moon), I would write a MessageBodyWriter<Bar> @Provider @Produces("application/json") public class BarWriter implements MessageBodyWriter<Bar> { ... } which