I am using Restlet v2.1m3.
I recently began working on adding JSON as an available media type on top of
existing XML functionality through JAXB. While I have had no real issues with
GET calls Accepting application/json, PUT calls seem to be ignoring the
availability of the Jackson converter.
Example resource contains:
@Get("xml|json")
public Card lookup()
@Put("xml|json:xml|json")
public Card change(Card card)
Traces of the conversion selection from Restlet:
GET:
2012-03-20 15:44:33,590 TRACE org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-21 - Delegating the call to the target Restlet
2012-03-20 15:44:33,590 TRACE org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-21 - Call score for the "" URI pattern: 1.0
2012-03-20 15:44:33,590 DEBUG org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-21 - Selected route: "" -> Finder for CardResource
2012-03-20 15:44:33,590 TRACE org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-21 - No characters were matched
2012-03-20 15:44:33,593 DEBUG org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-21 - Score of annotation "AnnotationInfo [javaMethod: public
com.s1.payments.services.dao.postcard.Card
com.s1.payments.services.resources.postcard.CardResource.lookup(),
resourceInterface: class
com.s1.payments.services.resources.postcard.CardResource, restletMethod: GET,
input: xml|json, output: xml|json, query: null]"= 0.5
2012-03-20 15:44:33,593 DEBUG org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-21 - Total score of variant "[text/xml]"= 0.08358333
2012-03-20 15:44:33,593 DEBUG org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-21 - Score of annotation "AnnotationInfo [javaMethod: public
com.s1.payments.services.dao.postcard.Card
com.s1.payments.services.resources.postcard.CardResource.lookup(),
resourceInterface: class
com.s1.payments.services.resources.postcard.CardResource, restletMethod: GET,
input: xml|json, output: xml|json, query: null]"= 0.5
2012-03-20 15:44:33,593 DEBUG org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-21 - Total score of variant "[application/xml]"= 0.08483333
2012-03-20 15:44:33,593 DEBUG org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-21 - Score of annotation "AnnotationInfo [javaMethod: public
com.s1.payments.services.dao.postcard.Card
com.s1.payments.services.resources.postcard.CardResource.lookup(),
resourceInterface: class
com.s1.payments.services.resources.postcard.CardResource, restletMethod: GET,
input: xml|json, output: xml|json, query: null]"= 0.5
2012-03-20 15:44:33,593 DEBUG org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-21 - Total score of variant "[application/json]"= 0.33333334
2012-03-20 15:44:33,650 DEBUG org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-21 - Converter selected for Card: JacksonConverter
PUT:
2012-03-20 16:14:52,654 TRACE org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-18 - Delegating the call to the target Restlet
2012-03-20 16:14:52,654 TRACE org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-18 - Call score for the "" URI pattern: 1.0
2012-03-20 16:14:52,654 DEBUG org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-18 - Selected route: "" -> Finder for CardResource
2012-03-20 16:14:52,654 TRACE org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-18 - No characters were matched
2012-03-20 16:14:52,658 DEBUG org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-18 - Score of annotation "AnnotationInfo [javaMethod: public
com.s1.payments.services.dao.postcard.Card
com.s1.payments.services.resources.postcard.CardResource.change(com.s1.payments.services.dao.postcard.Card),
resourceInterface: class
com.s1.payments.services.resources.postcard.CardResource, restletMethod: PUT,
input: xml|json, output: xml|json, query: null]"= 0.5
2012-03-20 16:14:52,658 DEBUG org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-18 - Total score of variant "[text/xml]"= 0.08358333
2012-03-20 16:14:52,658 DEBUG org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-18 - Score of annotation "AnnotationInfo [javaMethod: public
com.s1.payments.services.dao.postcard.Card
com.s1.payments.services.resources.postcard.CardResource.change(com.s1.payments.services.dao.postcard.Card),
resourceInterface: class
com.s1.payments.services.resources.postcard.CardResource, restletMethod: PUT,
input: xml|json, output: xml|json, query: null]"= 0.5
2012-03-20 16:14:52,658 DEBUG org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-18 - Total score of variant "[application/xml]"= 0.08483333
2012-03-20 16:14:52,658 DEBUG org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-18 - Score of annotation "AnnotationInfo [javaMethod: public
com.s1.payments.services.dao.postcard.Card
com.s1.payments.services.resources.postcard.CardResource.change(com.s1.payments.services.dao.postcard.Card),
resourceInterface: class
com.s1.payments.services.resources.postcard.CardResource, restletMethod: PUT,
input: xml|json, output: xml|json, query: null]"= 0.5
2012-03-20 16:14:52,658 DEBUG org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-18 - Total score of variant "[application/json]"= 0.33333334
2012-03-20 16:14:52,659 DEBUG org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-18 - The following converter was selected for the
[application/json] representation: org.restlet.ext.jaxb.JaxbConverter@166fdde
2012-03-20 16:14:52,663 WARN org.restlet.Component.InternalRouter.RESTServices
- qtp29056009-18 - Unable to unmarshal the XML representation
In the GET call, my headers are as follows (from WFetch):
Accept: application/json\r\n
Host: researchdev-vm\r\n
Authorization: Basic dGVzdDpQMHN0MWwxMG4=\r\n
In the PUT call, my headers are as follows (from WFetch):
Accept: application/json\r\n
Content-Type: application/json\r\n
Host: researchdev-vm\r\n
Content-Length:1249\r\n
Authorization: Basic dGVzdDpQMHN0MWwxMG4=\r\n
Anyone able to provide any insight into why this could be occurring? Based on
the variant scores JacksonConverter should be chosen, but there's not a lot of
debug information showing the actual connection between the Variant and the
chosen Converter in terms of decision making.
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2938058