You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Gabriel Guardincerri <gg...@gmail.com> on 2009/09/21 21:00:03 UTC
MIME type problem with a service that returns int and also an error
xml message
Hi,
We are using REST with JAX-RS and proxy clients.
We have this method
@GET
@Path("/{id}/replies/count")
int getNumberOfReplies(@PathParam("id") long id) throws
RemoteBridgeException, IOException;
The problem seems to be that since the return type is a primitive int, the
MINE type of the method is application/octet-stream. That seems to be true,
since the response is just a number, I mean, not an xml. The problem is that
we are using a text/xml payload to return a error messages. And there is the
conflict. We get a no writer found error when returning the error message.
So I added this
@Produces("text/xml")
But now the client says the there is no writer when the method is returning
a number.
So now I added
@Produces("text/xml,application/octet-stream")
But it isn't working.
Any ideas about how to solve this? I would prefer to only have text/xml, is
that possible?
Thanks,
Gabriel
--
View this message in context: http://www.nabble.com/MIME-type-problem-with-a-service-that-returns-int-and-also-an-error-xml-message-tp25530432p25530432.html
Sent from the cxf-user mailing list archive at Nabble.com.
RE: MIME type problem with a service that returns int and also an error xml message
Posted by "KARR, DAVID (ATTCINW)" <dk...@att.com>.
> -----Original Message-----
> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>
> We are using REST with JAX-RS and proxy clients.
>
> We have this method
>
> @GET
> @Path("/{id}/replies/count")
> int getNumberOfReplies(@PathParam("id") long id) throws
> RemoteBridgeException, IOException;
>
>
> The problem seems to be that since the return type is a primitive int,
> the
> MINE type of the method is application/octet-stream. That seems to be
> true,
> since the response is just a number, I mean, not an xml. The problem
is
> that
> we are using a text/xml payload to return a error messages. And there
> is the
> conflict. We get a no writer found error when returning the error
> message.
> So I added this
>
> @Produces("text/xml")
>
> But now the client says the there is no writer when the method is
> returning
> a number.
>
> So now I added
>
> @Produces("text/xml,application/octet-stream")
>
> But it isn't working.
>
> Any ideas about how to solve this? I would prefer to only have
> text/xml, is
> that possible?
I suggest you simply change the method and return type to return a
marshallable object that contains the value you want to produce. You
can't really overload return type protocols.
Re: MIME type problem with a service that returns int and also an
error xml message
Posted by Sergey Beryozkin <se...@iona.com>.
Hi
at the moment it is only text/plain that is supported for primitives.
so only registering a custom writer would convert them into xml.
I'll have to allocate some time later on and probably convert primitives
into something like
<int>3</int> and {"int":3} for JSON...
cheers, Sergey
Gabriel Guardincerri wrote:
>
> Hi,
>
> We are using REST with JAX-RS and proxy clients.
>
> We have this method
>
> @GET
> @Path("/{id}/replies/count")
> int getNumberOfReplies(@PathParam("id") long id) throws
> RemoteBridgeException, IOException;
>
>
> The problem seems to be that since the return type is a primitive int, the
> MINE type of the method is application/octet-stream. That seems to be
> true, since the response is just a number, I mean, not an xml. The problem
> is that we are using a text/xml payload to return a error messages. And
> there is the conflict. We get a no writer found error when returning the
> error message.
> So I added this
>
> @Produces("text/xml")
>
> But now the client says the there is no writer when the method is
> returning a number.
>
> So now I added
>
> @Produces("text/xml,application/octet-stream")
>
> But it isn't working.
>
> Any ideas about how to solve this? I would prefer to only have text/xml,
> is that possible?
>
> Thanks,
>
> Gabriel
>
--
View this message in context: http://www.nabble.com/MIME-type-problem-with-a-service-that-returns-int-and-also-an-error-xml-message-tp25530432p25530458.html
Sent from the cxf-user mailing list archive at Nabble.com.