Tuesday, January 12, 2010

Avoid namespace in Axis2

To avoid a namespace in the web service request in Axis2, you can use the following trick.

This will not work if you want to deploy multiple services or endpoints within the same code (services.xml).
But if you have one service and the services.xml of Axis2 is dedicated for it, then you can achieve the option of not sending /setting the namespace from the client.

For this, simply remove the serviceGroup tag from services.xml and keep only one service in the services.xml file.

Example : If your services.xml file is
<?xml version="1.0" encoding="UTF-8"?>
<serviceGroup>
<service name="MainService" scope="application">
<description>
MainService Service
</description>
<operation name="processSOAPRequest">
<messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
</operation>
<parameter name="ServiceClass">com.darel.server.service.MainService</parameter>
</service>
</serviceGroup>

Change it by removing the <serviceGroup> and put the service as the main element.
<?xml version="1.0" encoding="UTF-8"?>
<service name="MainService" scope="application">
<description>
MainService Service
</description>
<operation name="processSOAPRequest">
<messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
</operation>
<parameter name="ServiceClass">com.darel.server.service.MainService</parameter>
</service>

Since there is only one service, Axis2 does not make the namespace mandatory in the Soap request.

No comments:

Post a Comment