You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Aristo Togliatti <ar...@svt.se> on 2007/07/05 11:45:45 UTC

problems with custom module

Hi!

I am trying to write a custom module fo Axis2 and so far I only managed to 
get the INIT method to work, but nothing happen when I call the web 
service that is supposed to invoke the modules 'invoke' method...

The handler:

import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.engine.Handler;
import org.apache.axis2.handlers.AbstractHandler;

public class SimpleHandler extends AbstractHandler implements Handler {

        private String name;

        public String getName() {
                return name;
        }

        public InvocationResponse invoke(MessageContext msgContext)
                        throws AxisFault {

                System.out.println("Handler invoked");
 System.out.println(msgContext.getAxisOperation().toString());
                return InvocationResponse.CONTINUE;
        }

        public void revoke(MessageContext msgContext) {
                // log.info(msgContext.getEnvelope().toString());
        }

        public void setName(String name) {
                this.name = name;
        }
}


The module 


import java.security.Policy;

import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.AxisDescription;
import org.apache.axis2.description.AxisModule;
import org.apache.axis2.modules.Module;
import org.apache.neethi.Assertion;

public class SimpleHandlerModule implements Module {

        public void sayHello() {

        }

        public void init(ConfigurationContext configContext, AxisModule 
module)
                        throws AxisFault {// Initialize
 
                System.out.println("INIT MODULE");
                // the
                // module
        }

        public void shutdown(ConfigurationContext configurationContext)
                        throws AxisFault {
                // End of module processing
        }

        public void engageNotify(AxisDescription axisDescription) throws 
AxisFault {

        }

        public String[] getPolicyNamespaces() throws AxisFault {

                return null;

        }

        public void applyPolicy(Policy policy, AxisDescription 
axisDescription)
                        throws AxisFault {

        }

        public boolean canSupportAssertion(Assertion assertion) {

                return true;
        }

        public void applyPolicy(org.apache.neethi.Policy arg0, 
AxisDescription arg1) throws AxisFault {
                // TODO Auto-generated method stub
 
        }

}



module.xml


<module name="logging" class="SimpleHandlerModule">
   <inflow>
        <handler name="InFlowLogHandler" class="SimpleHandler">
        <order phase="PreDispatch" />
        </handler>
   </inflow>

   <outflow>
        <handler name="OutFlowLogHandler" class="SimpleHandler">
        <order phase="PreDispatch"/>
        </handler>
   </outflow>
</module>




services.xml

<service name="WSMonitor" scope="application">
    <description>
 
    </description>
    <module ref="logging"/>
    <messageReceivers>
        <messageReceiver 
            mep="http://www.w3.org/2004/08/wsdl/in-only"
    class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
        <messageReceiver
            mep="http://www.w3.org/2004/08/wsdl/in-out"
    class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
    </messageReceivers>
    <parameter name="ServiceClass">
        TestWS
    </parameter>
</service>


Thanks.

A.

Re: problems with custom module

Posted by Davanum Srinivas <da...@gmail.com>.
You have to "engage" the module say in axis2.xml (see how we engage
the addressing module in the default axis2.xml)

thanks,
dims

On 7/5/07, Aristo Togliatti <ar...@svt.se> wrote:
>
> Hi!
>
> I am trying to write a custom module fo Axis2 and so far I only managed to
> get the INIT method to work, but nothing happen when I call the web service
> that is supposed to invoke the modules 'invoke' method...
>
> The handler:
>
> import org.apache.axis2.AxisFault;
> import org.apache.axis2.context.MessageContext;
> import org.apache.axis2.engine.Handler;
> import org.apache.axis2.handlers.AbstractHandler;
>
> public class SimpleHandler extends AbstractHandler implements Handler {
>
>         private String name;
>
>         public String getName() {
>                 return name;
>         }
>
>         public InvocationResponse invoke(MessageContext msgContext)
>                         throws AxisFault {
>
>                 System.out.println("Handler invoked");
>
> System.out.println(msgContext.getAxisOperation().toString());
>                 return InvocationResponse.CONTINUE;
>         }
>
>         public void revoke(MessageContext msgContext) {
>                 // log.info(msgContext.getEnvelope().toString());
>         }
>
>         public void setName(String name) {
>                 this.name = name;
>         }
> }
>
>
> The module
>
>
> import java.security.Policy;
>
> import org.apache.axis2.AxisFault;
> import org.apache.axis2.context.ConfigurationContext;
> import org.apache.axis2.description.AxisDescription;
> import org.apache.axis2.description.AxisModule;
> import org.apache.axis2.modules.Module;
> import org.apache.neethi.Assertion;
>
> public class SimpleHandlerModule implements Module {
>
>         public void sayHello() {
>
>         }
>
>         public void init(ConfigurationContext configContext, AxisModule
> module)
>                         throws AxisFault {// Initialize
>
>                 System.out.println("INIT MODULE");
>                 // the
>                 // module
>         }
>
>         public void shutdown(ConfigurationContext configurationContext)
>                         throws AxisFault {
>                 // End of module processing
>         }
>
>         public void engageNotify(AxisDescription axisDescription) throws
> AxisFault {
>
>         }
>
>         public String[] getPolicyNamespaces() throws AxisFault {
>
>                 return null;
>
>         }
>
>         public void applyPolicy(Policy policy, AxisDescription
> axisDescription)
>                         throws AxisFault {
>
>         }
>
>         public boolean canSupportAssertion(Assertion assertion) {
>
>                 return true;
>         }
>
>         public void applyPolicy(org.apache.neethi.Policy arg0,
> AxisDescription arg1) throws AxisFault {
>                 // TODO Auto-generated method stub
>
>         }
>
> }
>
>
>
> module.xml
>
>
> <module name="logging" class="SimpleHandlerModule">
>    <inflow>
>         <handler name="InFlowLogHandler" class="SimpleHandler">
>         <order phase="PreDispatch" />
>         </handler>
>    </inflow>
>
>    <outflow>
>         <handler name="OutFlowLogHandler" class="SimpleHandler">
>         <order phase="PreDispatch"/>
>         </handler>
>    </outflow>
> </module>
>
>
>
>
> services.xml
>
> <service name="WSMonitor" scope="application">
>     <description>
>
>     </description>
>     <module ref="logging"/>
>     <messageReceivers>
>         <messageReceiver
>             mep="http://www.w3.org/2004/08/wsdl/in-only"
>
> class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
>         <messageReceiver
>             mep="http://www.w3.org/2004/08/wsdl/in-out"
>
> class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
>     </messageReceivers>
>     <parameter name="ServiceClass">
>         TestWS
>     </parameter>
> </service>
>
>
> Thanks.
>
> A.


-- 
Davanum Srinivas :: http://davanum.wordpress.com

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org