Return-Path: Delivered-To: apmail-cxf-users-archive@www.apache.org Received: (qmail 24263 invoked from network); 12 Mar 2009 04:01:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Mar 2009 04:01:31 -0000 Received: (qmail 60116 invoked by uid 500); 12 Mar 2009 04:01:25 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 60082 invoked by uid 500); 12 Mar 2009 04:01:25 -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 60071 invoked by uid 99); 12 Mar 2009 04:01:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Mar 2009 21:01:25 -0700 X-ASF-Spam-Status: No, hits=3.7 required=10.0 tests=DNS_FROM_OPENWHOIS,FORGED_HOTMAIL_RCVD2,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Mar 2009 04:01:16 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1Lhc6J-0002mV-AI for users@cxf.apache.org; Wed, 11 Mar 2009 21:00:55 -0700 Message-ID: <22469511.post@talk.nabble.com> Date: Wed, 11 Mar 2009 21:00:55 -0700 (PDT) From: harinair To: users@cxf.apache.org Subject: Re: JAXRS : howto produce XML and JSON? In-Reply-To: <3cfcba890902281235j3b10e88bl9efd910a15da788b@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Nabble-From: hari_g@hotmail.com References: <3cfcba890902280123v78e2ea10g53c594aec69717c6@mail.gmail.com> <3cfcba890902281235j3b10e88bl9efd910a15da788b@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Seems like this is not a very new thread. I hope you got this figured out. = In case you didn't or in case somebody else come here... here is the answer: You annotate it as @Produces({"application/xml","application/json"}) - see the value is an array. When the client needs JSON output it need to set header parameter "Accept" as "application/json" and call the service. The service will return data as JSON. I have also come across Restclient 2.3 (Available in code.google.com - search in google for Restclient). It is a wonderful client to test RESTful webservices. Hope this helps. Hari Gangadharan hanasakijiji wrote: >=20 > The annotation does not seem to like that. Also, how would the caller > / invoker specify if they want JSON or XML back? >=20 > [ERROR]Mojo: > [ERROR] org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile > [ERROR]FAILED for project: > [ERROR] com.hanaden:DemoRestful-WAR:war:1.0-SNAPSHOT > [ERROR]Reason: > [ERROR]com/service/impl/ServiceImpl.java.java:[23,10] annotation > values must be of the form 'name=3Dvalue' > [ERROR]com/service/impl/ServiceImpl.java.java:[23,29] annotation > values must be of the form 'name=3Dvalue' >=20 >=20 > On Sat, Feb 28, 2009 at 11:30 AM, Sergey Beryozkin > wrote: >> Hi, >> You can do something like >> >> @Produces("application/xml", "application/json") >> public SomeType get() {} >> >> Cheers, Sergey >> >> -----Original Message----- >> From: hanasaki jiji [mailto:hanasaki@gmail.com] >> Sent: 28 February 2009 09:24 >> To: users@cxf.apache.org >> Subject: JAXRS : howto produce XML and JSON? >> >> How would you go about creating a jaxrs that can produce both JSON and >> XML based on what the caller wants? =C2=A0Do you really need to write th= e >> class twice and annotate each differently? >> >=20 >=20 --=20 View this message in context: http://www.nabble.com/JAXRS-%3A-howto-produce= -XML-and-JSON--tp22260215p22469511.html Sent from the cxf-user mailing list archive at Nabble.com.