Return-Path: X-Original-To: apmail-cxf-users-archive@www.apache.org Delivered-To: apmail-cxf-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 17ACD9A9B for ; Wed, 14 Dec 2011 21:58:40 +0000 (UTC) Received: (qmail 50953 invoked by uid 500); 14 Dec 2011 21:58:39 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 50879 invoked by uid 500); 14 Dec 2011 21:58:39 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 50871 invoked by uid 99); 14 Dec 2011 21:58:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Dec 2011 21:58:39 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of guy@atomikos.com designates 72.52.162.75 as permitted sender) Received: from [72.52.162.75] (HELO host3.emwd.com) (72.52.162.75) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Dec 2011 21:58:29 +0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=atomikos.com; h=Received:Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Content-Transfer-Encoding:Message-Id:References:To:X-Mailer; b=Pu2caMVBe2h3GdZqgK3TwcZ6E+lJxrAw7g/w4FSOLlr/VN8UbJqHGKQrLUqnLPfo/XjuIlsG/VV55F13me8n0x1FSJUBCJM1BCJq14uvoE0SwxawdMuyxDJ+p3+c/M1C; Received: from 94-226-137-51.access.telenet.be ([94.226.137.51] helo=[10.0.1.5]) by host3.emwd.com with esmtpa (Exim 4.69) (envelope-from ) id 1Rawpy-0007jU-2l for users@cxf.apache.org; Wed, 14 Dec 2011 16:58:06 -0500 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1082.1) Subject: Re: Supporting custom JSON formats From: Guy Pardon In-Reply-To: <4EE91994.5050205@gmail.com> Date: Wed, 14 Dec 2011 22:58:07 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <6C8D252E-52FC-47F9-9DF6-5F974DA8BBB9@atomikos.com> References: <2A9342AB-2911-403A-8C2B-E386063E967D@atomikos.com> <4EE5D559.7030200@gmail.com> <4EC4AB48-8E63-49EC-A315-1D0546EF662D@me.com> <4EE91994.5050205@gmail.com> To: users@cxf.apache.org X-Mailer: Apple Mail (2.1082.1) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host3.emwd.com X-AntiAbuse: Original Domain - cxf.apache.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - atomikos.com X-Virus-Checked: Checked by ClamAV on apache.org You're welcome. CXF rocks:-) Guy On 14-dec-2011, at 22:48, Sergey Beryozkin wrote: On 14/12/11 18:44, Guy Pardon wrote: > My mistake, >=20 > Tried again and somehow it worked where it didn't before. Not sure = what I did wrong, sorry. no problems, thanks for trying it, Sergey >=20 > Guy >=20 > On 12-dec-2011, at 11:20, Sergey Beryozkin wrote: >=20 > Hi Guy >=20 > On 11/12/11 08:57, Guy Pardon wrote: >> Hi, >>=20 >> I am trying to define a custom hypermedia model (cf REST in Practice) = as the return type of my REST service. >>=20 >> With MIME type "application/json" this works, but with type = "application/vnd.example-com.foo+json" (which is what I want) this = fails, however. Calling the service URL gives: >>=20 >> "org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor = writeResponseErrorMessage >> WARNING: No message body writer has been found for response class = ListResult." >>=20 >> My service method: >>=20 >> @GET >> @Path("list") >> @Produces("application/vnd.example-com.foo+json") >> public ListResult retrieveList() { >> return new ListResult(); >> } >>=20 >> My configuration code looks like this: >>=20 >> JAXRSServerFactoryBean sf =3D new JAXRSServerFactoryBean(); >> JSONProvider prov =3D new JSONProvider(); >>=20 >> // setting custom mime types does not seem to work? >> List mimeTypes =3D new ArrayList(); >> mimeTypes.add("application/vnd.example-com.foo+json"); >> mimeTypes.add("application/json"); >> prov.setProduceMediaTypes(mimeTypes); >>=20 >> // following is regular CXF config as usual >> prov.setDropRootElement(true); >> sf.setProvider(prov); >> sf.setResourceClasses(ListService.class); >> sf.setResourceProvider(ListService.class, >> new SingletonResourceProvider(new ListService())); >> sf.setAddress("http://localhost:9000/"); >> sf.create(); >>=20 >>=20 >> Did I miss anything? I am using CXF 2.4.1... >=20 > I've updated one of the existing tests on the trunk and it works fine = for me, here is a trace: > ---------------------------- > ID: 1 > Address: http://localhost:9000/the/bookstore/books/123 > Http-Method: GET > Content-Type: */* > Headers: {Accept=3D[application/vnd.example-com.foo+json], = accept-encoding=3D[gzip;q=3D1.0, identity; q=3D0.5, *;q=3D0], = Cache-Control=3D[no-cache], connection=3D[keep-alive], = content-type=3D[*/*], Host=3D[localhost:9000], Pragma=3D[no-cache], = User-Agent=3D[Java/1.6.0_26]} > -------------------------------------- > 12-Dec-2011 10:15:28 org.apache.cxf.interceptor.LoggingOutInterceptor > INFO: Outbound Message > --------------------------- > ID: 1 > Response-Code: 200 > Content-Type: application/vnd.example-com.foo+json > Headers: {Date=3D[Mon, 12 Dec 2011 10:15:28 GMT]} > Payload: {"Book":{"id":123,"name":"CXF in Action"}} >=20 > I set produceMediaTypes on JSONProvider (from Spring), > can you confirm please > Accept: application/vnd.example-com.foo+json >=20 > is set on the wire, LoggingInInterceptor can help >=20 > Cheers, Sergey