BTW this is the same issue as "Variable response format" issue I posted
yesterday.
In my case the spec will define a request option to specify
responseFormat rather than
or in addition to ACCEPT header. The rationale is that ACCEPT header is
not universally supported
by servers and there is a need to have the information explicitly in the
URL.
I will provide more info in that thread.
Paul Sandoz wrote:
> Hi Guilhem,
>
> Glad you found a solution :-)
>
> In your case is the decision on what media to return based on the
> value of a query parameter?
>
> The selection with @ProduceMime is driven from the HTTP Accept header
> in the client request.
>
> Note that we are working to ensure better support for media types and
> dynamic selection but we are not quite there yet. 0.5 will have
> support dynamic selection based on 'variants' that will work in
> conjunction with @ProduceMime. When implemented i will send out an
> example.
>
> For 0.6 we plan to investigate support for suffices in the URI path
> like ".xml" and ".png" that "do the right thing" w.r.t to method
> selection and the Accept header.
>
> Paul.
>
> We are working
> guilhem legal wrote:
>> Thank's for your help, but i found my solution in the example of
>> jersey release (i should read it before asking on the list)
>> it is possible to change dynamically the mime type like this :
>>
>> @HttpMethod("GET")
>> public Response treatGETrequest() throws IOException {
>> String help = "<xml>blablabla</xml>";
>> File img = new File("C:\\198543.png");
>> if ( //cas 1)
>> Response r = Response.Builder.representation(help,
>> "text/xml").header("resource3-header", "text/xml").build();
>> else
>> Response r = Response.Builder.representation(img,
>> "image/png").header("resource3-header", "image/png").build();
>> return r;
>> }
>>
>> Guilhem Legal
>>
>> guilhem legal a écrit :
>>> I'll try to put two GET methods in my class one with
>>> @produceMime("text/xml) and one with @produceMime("image/png) but it
>>> always the first whitch is call.
>>> But what i really want is to received a list of parameter and then
>>> after some process i will decided if i send xml or an image.
>>>
>>> Christian a écrit :
>>>> Yes you can (and should) have different GET methods in the same class.
>>>> I think what you're looking for is having two get methods on the
>>>> same path
>>>> with different produced mime types ? should work fine.
>>>>
>>>> 2007/12/6, guilhem legal <guilhem.legal_at_geomatys.fr>:
>>>>
>>>>> I'm working on the implementation of an OGC so i my query must be :
>>>>> http://localhost:8080/WMServerJ/wms?param1=value¶m2...... (in GET
>>>>> only)
>>>>>
>>>>> I really begin with jersey , can we do 2 @HttpMethod("GET") in a same
>>>>> class and how we can specify that a want to enter in some function
>>>>> and
>>>>> not in another?
>>>>>
>>>>> Guilhem Legal
>>>>>
>>>>> Christian a écrit :
>>>>>
>>>>>> Hi Guilhem,
>>>>>>
>>>>>> I don't know if changing the mime type programmatically is
>>>>>> possible or
>>>>>>
>>>>> not,
>>>>>
>>>>>> you will want to hear the response from other users.
>>>>>> But I guess it would be better practice to have different functions
>>>>>>
>>>>> serving
>>>>>
>>>>>> the different response anyway.
>>>>>> Is there anything that prevents you from doing so ?
>>>>>>
>>>>>>
>>>>>> 2007/12/6, guilhem legal <guilhem.legal_at_geomatys.fr>:
>>>>>>
>>>>>>
>>>>>>> hi!
>>>>>>> I am a beginner with jersey and i have a little issue :
>>>>>>>
>>>>>>> i would like to return different Mime type from the same method
>>>>>>> (image/png or text/xml).
>>>>>>> if i put this @ProduceMime("image/png") on my method this work
>>>>>>> when i
>>>>>>> return a File, but i can't return xml.
>>>>>>> if i put @ProduceMime("text/xml") i can't return image.
>>>>>>> and if i put @ProduceMime("*/*) and i return a file this works
>>>>>>> for both
>>>>>>> but the browser does not open the file and ask me to download it.
>>>>>>>
>>>>>>> can we change dynamically the ProduceMime Type?
>>>>>>> or can we adjust the return type with @ProduceMime("*/*) to
>>>>>>> display an
>>>>>>> image? (for xml i can return string but for image?)
>>>>>>>
>>>>>>> if you have a solution to my probleme please reply me.
>>>>>>>
--
Regards,
Farrukh Najmi
Web: http://www.wellfleetsoftware.com