faizan khan

Greenhorn
+ Follow
since Jan 30, 2020
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by faizan khan

Output:-
creditsoap.MyHandler:26 - null
creditsoap.MyHandler:27 - [MessageContext: logID=1322a5dc9e7e05ce88b7cfd80253104399d001e5e79bc6ca]
creditsoap.MyHandler:28 - null
2 years ago
Hi Stephan van Hulst,
Thanks for replying, actually this is not a new project and we wanted to add a handler. Below i have attached all details:-

Handler class:-

package org.apache.axis2.handlers.creditsoap;

import java.util.Iterator;

import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPMessage;

import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.engine.Handler;
import org.apache.axis2.handlers.AbstractHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.commons.lang.StringUtils;

public class MyHandler extends AbstractHandler implements Handler{
private static final Log log1 = LogFactory.getLog(MyHandler.class);
@Override
public InvocationResponse invoke(MessageContext arg0) throws AxisFault {
log.info(arg0.getClass());
log.info(arg0.getLogIDString());
log.info(arg0.getEnvelope().toString());

log.info(arg0.getCurrentMessageContext());
log.info(arg0.getCurrentMessageContext().getAxisService());

return InvocationResponse.CONTINUE;
}

}


HandlerModule class:-

package org.apache.axis2.handlers.creditsoap;

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;
import org.apache.neethi.Policy;

public class MyHandlerModule implements Module{

@Override
public void applyPolicy(Policy arg0, AxisDescription arg1) throws AxisFault {
// TODO Auto-generated method stub

}

@Override
public boolean canSupportAssertion(Assertion arg0) {
// TODO Auto-generated method stub
return true;
}

@Override
public void engageNotify(AxisDescription arg0) throws AxisFault {
// TODO Auto-generated method stub

}

@Override
public void init(ConfigurationContext arg0, AxisModule arg1) throws AxisFault {
// TODO Auto-generated method stub

}

@Override
public void shutdown(ConfigurationContext arg0) throws AxisFault {
// TODO Auto-generated method stub

}

}

module.xml:-
<!--
 ~ Licensed to the Apache Software Foundation (ASF) under one
 ~ or more contributor license agreements. See the NOTICE file
 ~ distributed with this work for additional information
 ~ regarding copyright ownership. The ASF licenses this file
 ~ to you under the Apache License, Version 2.0 (the
 ~ "License"); you may not use this file except in compliance
 ~ with the License. You may obtain a copy of the License at
 ~
 ~ http://www.apache.org/licenses/LICENSE-2.0
 ~
 ~ Unless required by applicable law or agreed to in writing,
 ~ software distributed under the License is distributed on an
 ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 ~ KIND, either express or implied. See the License for the
 ~ specific language governing permissions and limitations
 ~ under the License.
 -->

<module name="creditsoap" class="org.apache.axis2.handlers.creditsoap.MyHandlerModule">
   <InFlow>
       <handler name="InFlowCreditSoapHandler" class="org.apache.axis2.handlers.creditsoap.MyHandler">
           <order phase="creditSoapPhase"/>
       </handler>
   </InFlow>

   <OutFlow>
       <handler name="OutFlowCreditSoapHandler" class="org.apache.axis2.handlers.creditsoap.MyHandler">
           <order phase="creditSoapPhase"/>
       </handler>
   </OutFlow>

   <OutFaultFlow>
       <handler name="FaultOutFlowCreditSoapHandler" class="org.apache.axis2.handlers.creditsoap.MyHandler">
           <order phase="creditSoapPhase"/>
       </handler>
   </OutFaultFlow>

   <InFaultFlow>
       <handler name="FaultInFlowCreditSoapHandler" class="org.apache.axis2.handlers.creditsoap.MyHandler">
           <order phase="creditSoapPhase"/>
       </handler>
   </InFaultFlow>
</module>

axis2.xml:-
<phaseOrder type="InFlow">
       <!--  System predefined phases       -->
       <phase name="Transport">
           <handler name="RequestURIBasedDispatcher"
                    class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher">
               <order phase="Transport"/>
           </handler>
           <handler name="SOAPActionBasedDispatcher"
                    class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher">
               <order phase="Transport"/>
           </handler>
       </phase>
       <phase name="Addressing">
           <handler name="AddressingBasedDispatcher"
                    class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
               <order phase="Addressing"/>
           </handler>
       </phase>
       <phase name="Security"/>
       <phase name="PreDispatch"/>
       <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
           <handler name="RequestURIBasedDispatcher"
                    class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
           <handler name="SOAPActionBasedDispatcher"
                    class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
           <handler name="RequestURIOperationDispatcher"
                    class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
           <handler name="SOAPMessageBodyBasedDispatcher"
                    class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
           <handler name="HTTPLocationBasedDispatcher"
                    class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
           <handler name="GenericProviderDispatcher"
                    class="org.apache.axis2.jaxws.dispatchers.GenericProviderDispatcher"/>
           <handler name="MustUnderstandValidationDispatcher"
                    class="org.apache.axis2.jaxws.dispatchers.MustUnderstandValidationDispatcher"/>
       </phase>
       <phase name="RMPhase"/>
       <!--  System predefined phases       -->
       <!--   After Postdispatch phase module author or service author can add any phase he want      -->
       <phase name="creditSoapPhase"/>
        <phase name="OperationInPhase">
           <handler name="MustUnderstandChecker"
                    class="org.apache.axis2.jaxws.dispatchers.MustUnderstandChecker">
2 years ago
hi shivendra tripathi, i am getting messageContext value as null, please provide help if you have any solution
2 years ago