users@jersey.java.net

[Jersey] Jersey Response problem

From: Sohaib Yasir <sohaib.yasir_at_ebricks-inc.com>
Date: Wed, 13 Nov 2013 14:01:08 +0500

Hi,
I want to inquire about response returned by the jersey method. Please
consider the following scenario to understand me the process.

*Server Side:*

@Produces("application/json")

public XMLResult xyz() {

 return new XMLResult();
}

*Client Side:*

Client calls method *xyz()* and pass *header contents* as "
*application/json*" then it return json object in response and if Client
pass nothing in header it returns *XML object*.



XMLResult is class which returns XML object.


*Question:* Method xyz() is forced to produced return JSON object through
annotation @Produces. Then how it is able to produce XML object when client
does not set any type of header contents.


please help me out as i am very much confuse about the response. according
to me it should through an exception because i am returning XML object and
method is forced to produce JOSN object.

Regards,
Sohaib Yasir