Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Use Aspectj during web services invocation

Hi,

     I wanted to use aspectj during invocation of web service from other service. For that i wanted to know how to specify the jointpoint.

Web services code:

import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;

public class MiddleSimpleInterest
{
    public static void main(String[] args) throws AxisFault
    {
       ServiceClient client = new ServiceClient();
       Options opts = new Options();
       opts.setTo(new EndpointReference("http://localhost:8088/axis2/services/SimpleIntJava"));
       opts.setAction("urn:findInterest");
       client.setOptions(opts);
       OMElement res = client.sendReceive(createPayLoad());
       System.out.println(res);
    }
   private static OMElement createPayLoad()
   {
        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace omNs = fac.createOMNamespace("http://simpleintjava", "ns");
        OMElement method = fac.createOMElement("findInterest", omNs);
        OMElement value = fac.createOMElement("p", omNs);
        value.setText("1000");
        method.addChild(value);
        return method;
    }
}

Corresponding Aspectj code:
public aspect MiddlewareAspect
{
pointcut beforeaspect():execution(* *.sendReceive(..));
 
        pointcut beforeexeaspect():execution(* EndpointReference(..));
        before():beforeaspect()
        {
                System.out.println("~~~~~~~~~~~~~~~~~~~~~~");
                System.out.println("====Before sendReceive=====");
                System.out.println("~~~~~~~~~~~~~~~~~~~~~~");
         }
         before():beforeexeaspect()
         {
               System.out.println("~~~~~~~~~~~~~~~~~~~~~~");
               System.out.println("====Before EndpointReference=====");
               System.out.println("~~~~~~~~~~~~~~~~~~~~~~");
         }
}

Error:

      For the above aspectj code i got the exception "Advice didn't match".


 How can i specify those 2 join points? Is it possible in aspectj?

Thanks,

Back to the top