axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Public Network Services <publicnetworkservi...@gmail.com>
Subject RESTful Web Services using Axis2 and Mapped JSON
Date Sat, 12 Nov 2011 12:41:25 GMT
Hi...

I have been trying for days now to implement a simple REST web service
using Axis 1.6.2 in Jetty 8.0.4, with serialization and deserialization in
JSON, but with limited success: all the code works fine with SOAP, but not
with REST. So, any help is very welcome.

For start, I am trying to make the sample "MyService" in
samples/userguide/example1 work with samples/userguide/clients/RESTClient.
The service works fine with SOAP, but after adding

options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);


it stops working, returning a cryptic AxisFault message referring to a
NullPointerException, without any further information.

I am aware of issue 5158 (https://issues.apache.org/jira/browse/AXIS2-5158),
but the services.xml file in the repository/services/sample-MyService.aar
archive already uses the required RawXMLINOutMessageReceiver and I have
declared "application/json" in both the client and the service axis2.xml
configuration file.

TCPMon shows that the request is transmitted in proper Mapped JSON (I don't
want Badgerfish) but, as already mentioned, an AxisFault is returned.

I need to make this thing work asap and have run out of ideas. Any clues?

Thanks!

PS: These are the formatting statements in my axis2.xml files (client and
service sides).

    <!-- ================================================= -->
    <!-- Message Receivers -->
    <!-- ================================================= -->
    <messageReceivers>
        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"

class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"

class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
        <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only"

class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
        <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out"

class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
        <messageReceiver mep="http://www.w3.org/ns/wsdl/in-only"

class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
        <messageReceiver mep="http://www.w3.org/ns/wsdl/in-out"

class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
    </messageReceivers>

    <!-- ================================================= -->
    <!-- Message Formatter -->
    <!-- ================================================= -->
    <messageFormatters>
<messageFormatter contentType="application/json"

 class="org.apache.axis2.json.JSONMessageFormatter"/>
        <messageFormatter contentType="application/x-www-form-urlencoded"

 class="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/>
        <messageFormatter contentType="multipart/form-data"

 class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/>
        <messageFormatter contentType="application/xml"

 class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
        <messageFormatter contentType="text/xml"

 class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
        <messageFormatter contentType="application/soap+xml"

 class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
    </messageFormatters>

    <!-- ================================================= -->
    <!-- Message Builders -->
    <!-- ================================================= -->
    <messageBuilders>
        <messageBuilder contentType="application/json"
                        class="org.apache.axis2.json.JSONOMBuilder"/>
        <messageBuilder contentType="application/xml"

 class="org.apache.axis2.builder.ApplicationXMLBuilder"/>
        <messageBuilder contentType="application/x-www-form-urlencoded"

 class="org.apache.axis2.builder.XFormURLEncodedBuilder"/>
        <messageBuilder contentType="multipart/form-data"

 class="org.apache.axis2.builder.MultipartFormDataBuilder"/>
    </messageBuilders>

Mime
View raw message