users@jersey.java.net

Re: consume xml

From: guilhem legal <guilhem.legal_at_geomatys.fr>
Date: Wed, 23 Jan 2008 09:59:16 +0100

No I don't get an exception on the server side, it looks like i never
received the request.
And yes I want to handle multiple JAXB type. I m using jersey 0.4, maybe
I will pass to 0.5 to see if there is any change.
Maybe a solution is that :

   @HttpMethod("POST")
   @ConsumeMime("text/xml")
   public Response handleObject1Xml(Object1 request) throws
JAXBException {
       ----------------------------------------------------------------
   }

   @HttpMethod("POST")
   @ConsumeMime("text/xml")
   public Response handleObject2Xml(Object2 request) throws
JAXBException {
       ----------------------------------------------------------------
   }

it not really what i want but is this working?

Guilhem Legal

Paul Sandoz a écrit :
> guilhem legal wrote:
>> hi!
>>
>> I'm trying to do a simple thing (I think) with jersey but its not
>> working.
>> I want to handle two different POST request with diferent MIME type.
>> I use an other application whitch is supposed to send the request :
>>
>
> Are you getting an exception on the server side when the client POSTs
> the request with the content type of "text/xml" ?
>
> I just wrote a little example and verified that i get an exception in
> this case, with the error:
>
> Caused by: java.lang.IllegalArgumentException: A message body reader
> for Java type, class java.lang.Object, and MIME media type, text/xml,
> was not found
>
> Note i am using Jersey 0.6 (but for this case it is equivalent to that
> in 0.5).
>
> I think the problem is you are using the Object type for the request
> entity of the doPOSTXml method. The runtime does not know what to do
> with Object type. If you use an explicit JAXB type then it should work.
>
> But maybe you want to handle multiple JAXB types for the request
> entity? Unfortunately that is not currently possible. I am not sure it
> is possible given the current way message body readers work, i would
> need to look more closely at this.
>
> Paul.
>
>> my code :
>>
>> @HttpMethod("GET")
>> public Response doGET() throws JAXBException {
>>
>> return treatIncommingRequest();
>> }
>> @HttpMethod("POST")
>> @ConsumeMime("application/x-www-form-urlencoded")
>> public Response doPOSTKvp(String request) throws JAXBException {
>> -------------------------------------------------------
>> }
>> @HttpMethod("POST")
>> @ConsumeMime("text/xml")
>> public Response doPOSTXml(Object request) throws JAXBException {
>> ----------------------------------------------------------------
>> }
>>
>> It never enter in the method doPOSTXml. So have i make a mistake?
>>
>> Guilhem Legal
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>