You have to use the RawXMLInOutMessageReceiver in the services.xml of your service. Refer [1] for services.xml syntax.
Thanks, ~Isuru [1] http://wso2.org/library/2060 On Fri, Nov 11, 2011 at 11:16 AM, Public Network Services < publicnetworkservi...@gmail.com> wrote: > Hi... > > I am trying to use Axis2 1.6.1 with Jetty for a RESTful web service in > which I want data to travel back and forth serialized in JSON. Using the > POJO deployment scenario, I am hitting the well-known issue 5158 ( > https://issues.apache.org/jira/browse/AXIS2-5158) with the "namespace > mismatch" exception. > > Having a look at your relevant article ( > http://isurues.wordpress.com/2009/10/06/how-to-use-axis2-json/), I am not > sure how to switch to the RawXMLInOutMessageReceiver. As a matter of fact, > RawXMLInOnly and RawXMLInOut are the only message receivers that appear in > my axis2.xml files, at both the client and the service sides, but the > problem persists. I am using an RPCServiceClient object, in which I run > the invokeBlocking(qname, args, returnTypes) method, which works just fine > with SOAP but not with JSON. Running the JSONIntegrationTest still produces > the same error. > > Even with the simple RESTClient sample included in the Axis2 distribution, > I get and exception if I switch to JSON: > > options.setProperty(Constants.Configuration.MESSAGE_TYPE, > "application/json"); > > > Exception from Jetty: > > java.lang.NullPointerException > at > org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerialize(OMSourcedElementImpl.java:695) > at > org.apache.axiom.om.impl.llom.OMSourcedElementImpl.serializeAndConsume(OMSourcedElementImpl.java:758) > at > org.apache.axis2.json.AbstractJSONMessageFormatter.writeTo(AbstractJSONMessageFormatter.java:174) > at > org.apache.axis2.transport.http.CommonsHTTPTransportSender.sendUsingOutputStream(CommonsHTTPTransportSender.java:364) > at > org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:241) > at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443) > at > org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:45) > at > org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110) > at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181) > at > org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172) > at > org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:755) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) > at > org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:558) > at > org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:488) > at > org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119) > at > org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:483) > at > org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233) > at > org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:973) > at > org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:417) > at > org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192) > at > org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:907) > at > org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) > at > org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250) > at > org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149) > at > org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110) > at org.eclipse.jetty.server.Server.handle(Server.java:346) > at > org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:442) > at > org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:941) > at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:893) > at > org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:224) > at > org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51) > at > org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586) > at > org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44) > at > org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598) > at > org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533) > at java.lang.Thread.run(Thread.java:662) > > -- Technical Lead, WSO2 Inc. http://wso2.org/ Blog : http://isurues.wordpress.com/