Thursday, November 19, 2009

How to generate a non-secured response to a secured request?

In other words - how to avoid rampart being executed in the OutFlow of a particular service.

1. Add a new phase [NoSecurity] in global axis2.xml under OutFlow - just before the Security phase

<phaseOrder type="OutFlow">
<phase name="soapmonitorPhase"/>
<phase name="OperationOutPhase"/>
<phase name="RMPhase"/>
<phase name="PolicyDetermination"/>
<phase name="MessageOut"/>
<phase name="NoSecurity"/>
<phase name="Security"/>
</phaseOrder>
2. Create a module [say, nosecuity] with handler having the following logic.

public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
msgContext.setCurrentHandlerIndex(msgContext.getCurrentHandlerIndex() + 2);
return InvocationResponse.CONTINUE;
}
You can download the eclipse project for this module from here.

3. Engage this module to the service you want to remove security frome OutFlow.

<module ref="nosecurity" />

Monday, November 16, 2009

How to use Axis2 Dynamic Client to invoke Secured Web Services

Axis2 Dynamic Client is an extension to the Axis2 ServiceClient; it can be used to invoke secured web services relieving the burden of locally maintaining policy files in the client's end.
This post explains how to use Axis2 Dynamic Client to invoke a secured service.

Sunday, November 1, 2009

Exception in thread "main" java.lang.NoClassDefFoundError: edu/emory/mathcs/backport/java/util/concurrent/locks/ReadWriteLock

Exception :

[java] Exception in thread "main" org.apache.axis2.AxisFault: java.lang.NoClassDefFoundError: edu/emory/mathcs/backport/java/util/concurrent/locks/ReadWriteLock
[java]at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:435)
[java]at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:371)
[java]at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
[java]at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
[java]at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
Solution :Copy backport-util-concurrent jar from here to the classpath.