You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Mahesh kumar <mm...@gmail.com> on 2011/07/12 19:55:02 UTC
Axis2 Converting SOAP+XML into REST+JSON
I'm not sure whether I can send this mail to dev list. But I couldn't find
where I miss.
I have created axis2 webservice using SOAP+XML. Now my client want me to use
REST+JSON. I followed this article: http://www.marcusschiesser.de/?p=130
Calling
http://localhost:8080/axis2/services/Version/getVersion?response=application/json
from
browser is always returning
<ns:getVersionResponse xmlns:ns="http://axisversion.sample">
<ns:return>Hi - the Axis2 version is 1.6.0</ns:return>
</ns:getVersionResponse>
But I want the response in JSON format. I couldn't figureout what went
wrong. For more details I have attached axis2.xml.
I added system out in DynamicResponseHandler, and it never called.
public class DynamicResponseHandler extends AbstractHandler
{
public Handler.InvocationResponse invoke(MessageContext messageContext)
throws AxisFault
{
OperationContext operationContext =
messageContext.getOperationContext();
if (operationContext != null) {
MessageContext inMessageContext =
operationContext.getMessageContext("In");
if (inMessageContext != null) {
HttpServletRequest request =
(HttpServletRequest)inMessageContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
if (request != null) {
String responseFormat = request.getParameter("response");
if (responseFormat != null) {
Parameter parameter = getParameter(responseFormat);
if (parameter != null)
responseFormat = (String)parameter.getValue();
messageContext.setProperty("messageType", responseFormat);
System.out.println("Setting message type");
}
}
}
}
return Handler.InvocationResponse.CONTINUE;
}
}
I'm missing something. Please guide me to fix it