title: Axis2 with JSON Support
body: <p>I have an Axis2 web service that's already deployed, and which communicates with clients using SOAP. There's a new requirement now to enable REST calls by sending JSON requests and receiving JSON formatted responses.</p>
  
  <p>Following this small tutorial: <a href="http://code.google.com/p/jsonp-support-for-axis2/wiki/OneStopPage" rel="nofollow">http://code.google.com/p/jsonp-support-for-axis2/wiki/OneStopPage</a></p>
  
  <p>I was able to configure my Axis 2 web service correctly. Using my browser, I used the following URL to return a Student object:</p>
  
  <pre><code>http://localhost:8181/Axis2Json/services/StudentService/getStudent?response=application/json&amp;value=3
  </code></pre>
  
  <p><strong>OUTPUT :</strong></p>
  
  <pre><code>{"return":{"@type":"ax21:Student","age":25,"firstName":"Mouhammed","lastName":"Soueidane"}}
  </code></pre>
  
  <p>The problem is that the returned JSON, doesn't look like a standard JSON representation (Not even in badgerfish format). So for instance, if I want to call a method called "setStudent" which takes in a Student object, I really have no clue of the JSON string that I need to pass to it.</p>
  
  <p>I tried so many stuff, most of which resulted in a casting exception <code>(java.lang.ClassCastException: java.lang.String cannot be cast to org.codehaus.jettison.json.JSONObject)</code></p>
  
  <p>Does anyone have an idea about how to allow an Axis 2 web service to use both SOAP and JSON, based on the content type of the client?</p>