IgorShare Thoughts and Ideas

Consulting and Training

Archive for the ‘XStream’ Category

XML/JSON symmetric REST web services providers for Jersey

Posted by Igor Moochnick on 07/27/2009

Many times I’ve been asked to provide a set of Web Services interfaces where both JSON and XML clients can communicate with the server. Primarily it’s done for a set of reasons:

  1. XML is very convenient to use for inter-service communication.
  2. JSON is great for AJAX (web) clients. It’s perfect for GWT too.

In the recent project we’ve been using XStream for all serialization aspects and, since it can serialize both to XML and JSON, it was plugged into Jersey as a provider too. Following you can see XML and JSON providers implemented using XStream library.

XML Provider (annotated to be a default provider, it’ll be used if no Content-Type or Accept headers provided):

Read the rest of this entry »

Advertisements

Posted in GWT, Java, Jersey, JSON, REST, Tutorials, XML, XStream | 2 Comments »

 
%d bloggers like this: