Hi

I'm newbie to webservice and axis2. I'm getting problem while invoking the
web service using JSON. I have specified the following in axis2.xml in
service.

<messageFormatter contentType="application/json"
                class="org.apache.axis2.json.JSONMessageFormatter" />

<messageBuilder contentType="application/json"
                        class="org.apache.axis2.json.JSONOMBuilder" />

In client I used the following:

String endpoint = "
http://localhost:8080/axis2/services/WeatherService.WeatherServiceHttpEndpoint/";;


                        File configFile = new File("axis2.xml");
          ConfigurationContext configurationContext =
ConfigurationContextFactory
                  .createConfigurationContextFromFileSystem(null, configFile

                          .getAbsolutePath());

          ServiceClient client = new ServiceClient(configurationContext,
null);
          Options options = new Options();
          client.setOptions(options);
          options.setTo(new EndpointReference(endpoint));
          options.setProperty(Constants.Configuration.MESSAGE_TYPE,
"application/json");
          options.setProperty(Constants.Configuration.HTTP_METHOD,
Constants.Configuration.HTTP_METHOD_POST);

          OMFactory fac = OMAbstractFactory.getOMFactory();
          OMNamespace omNs = fac.createOMNamespace("http://somenamespace.com";,
"ns");
          OMElement rootElement = fac.createOMElement("doAuthenticate",
omNs);

          OMElement appId = fac.createOMElement("userName", omNs,
rootElement);
          appId.setText("ApacheRestDemo");

          OMElement query = fac.createOMElement("password", omNs,
rootElement);
          query.setText("test");

          System.out.println(rootElement);

          OMElement response = client.sendReceive(rootElement);

          System.out.println("Sent 'Hello!', got '" + response + "'");

While invoking this using AXIOM, I'm getting the following error message:
org.apache.axis2.AxisFault: Mapped formatted JSON with namespaces are not
supported in Axis2. Make sure that your request doesn't include namespaces
or use the Badgerfish convention

When I set OMNamespace omNs = null in client, I'm getting
java.lang.IllegalArgumentException: The MessageContext does not have an
associated SOAPFault.

I'm getting same error when message type is application/json/badgerfish
java.lang.IllegalArgumentException: The MessageContext does not have an
associated SOAPFault.

But it is working fine if there is no message type.

Please let me know if you want addition details.

Regards,
Mahesh Kumar

Reply via email to