axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From satyapriya sahoo <sahoo.satyapr...@gmail.com>
Subject facing problem while logging the soap messages
Date Tue, 18 Aug 2015 08:22:11 GMT
Hi,

 I am using Axis2-1.5.1 with JDK1.6.

I have written 1 module to write the SOAP Messages. Here I am acting as a
*server*.
When it is trying to write the SOAP ENVELOPE IN Message, it is throwing the
Bellow Exception

18 Aug 2015 13:03:41,956 - ERROR invoke (TestHandler.java:66) - Exception
Occured while logging the message
*org.apache.axiom.om.OMException: Parser has already reached end of the
document. No siblings found*
at
org.apache.axiom.om.impl.llom.OMElementImpl.getNextOMSibling(OMElementImpl.java:339)
at
org.apache.axiom.om.impl.traverse.OMChildrenIterator.next(OMChildrenIterator.java:102)
at
org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:953)
at
org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:937)
at
org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:227)
at
org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:937)
at org.apache.axiom.om.impl.llom.OMNodeImpl.serialize(OMNodeImpl.java:387)
at
org.apache.axiom.om.impl.llom.OMElementImpl.toString(OMElementImpl.java:1106)
at
com.synchronoss.webservice.itsm.logger.TestHandler.invoke(TestHandler.java:34)
at org.apache.axis2.engine.Phase.invoke(Phase.java:318)
at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:251)
at org.apache.axis2.engine.AxisEngine.sendFault(AxisEngine.java:508)
at
org.apache.axis2.transport.http.AxisServlet.handleFault(AxisServlet.java:423)
at
org.apache.axis2.transport.http.AxisServlet.processAxisFault(AxisServlet.java:386)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:176)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at
weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at
weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at
weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at
weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:183)
at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3717)
at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at
weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at
weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at
weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)


STEPS I followed :

*Created 1 TestModule.java*

package com.test.logger;

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 TestModule 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 false;
}

@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
}

}

*2) Created 1 Handler class*
package com.test.logger;

import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.context.OperationContext;
import org.apache.axis2.engine.Handler;
import org.apache.axis2.handlers.AbstractHandler;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class TestHandler extends AbstractHandler implements Handler{

private static Log log = LogFactory.getLog(TestHandler.class);

private String name;

public String getName() {
return name;
}

public void setName(String name) {
log.debug("Setting name as :"+name);
this.name = name;
}

public InvocationResponse invoke(MessageContext msgContext) throws
AxisFault {
try{
log.debug("Received Request.");
StringBuilder stringBuilder=new StringBuilder();
OperationContext operationContext = msgContext.getOperationContext();
if(operationContext!=null){
MessageContext inMessage =
operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
*String inSoapRequest = inMessage.getEnvelope().toString();
 <-------------------------------------------------------------------------------------Facing
Problem here*

MessageContext outMessage =
operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
MessageContext faultMessage =
operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_FAULT_VALUE);

if(outMessage==null&&faultMessage==null){
log.debug("\n--------------Request Received(NEW
LOGGER)--------------\n"+inSoapRequest);
}
if(outMessage!=null || faultMessage!=null){
stringBuilder.append("\n-------IN MESSAGE(NEW LOGGER)-------\n");

stringBuilder.append(inSoapRequest);
stringBuilder.append("\n-------OUT MESSAGE(NEW LOGGER)-------\n");

if(outMessage!=null){

String outMessageEnvelope = outMessage.getEnvelope().toString();
stringBuilder.append(outMessageEnvelope);
}

if(faultMessage!=null){
stringBuilder.append("\n-------FAULT MESSAGE(NEW LOGGER)-------\n");
String faultMessagerEnvelope = faultMessage.getEnvelope().toString();
stringBuilder.append(faultMessagerEnvelope);
//                                   stringBuilder.append("\n Fault
Envelope : "+faultMessagerEnvelope+"\n");
//                                   stringBuilder.append("\n Fault Reason
: "+faultMessage.getFailureReason().getMessage()+"\n");
//
faultMessage.getFailureReason().printStackTrace();
}

log.debug("\nTRANSACTION START (NEW LOGGER):"+stringBuilder.toString()+
"\nTRANSACTION END\n");
}

}
}catch(Exception e){
log.error("Exception Occured while logging the message ",e);
}
return InvocationResponse.CONTINUE;
}

public void revoke(MessageContext msgContext) {
log.debug("Revoking Started");
log.info(msgContext.getEnvelope().toString());
log.debug("Revoking completed");
}

}

3) U*nder META-INF folder, I put the module.xml*

<module name="TestModule" class="com.test.logger.TestModule">
    <InFlow>
        <handler name="InFlowLogHandler"
class="com.test.logger.TestHandler">
            <order phase="TestPhase" />
        </handler>
    </InFlow>

    <OutFlow>
        <handler name="OutFlowLogHandler"
class="com.test.logger.TestHandler">
            <order phase="TestPhase"/>
        </handler>
    </OutFlow>

    <OutFaultFlow>
        <handler name="FaultOutFlowLogHandler"
class="com.test.logger.TestHandler">
            <order phase="TestPhase"/>
        </handler>
    </OutFaultFlow>

    <InFaultFlow>
        <handler name="FaultInFlowLogHandler"
class="com.test.loggerTestHandler">
            <order phase="TestPhase"/>
        </handler>
    </InFaultFlow>
</module>

*4) Then I created the .mar file and put it under AXIS2/WEB-INF/modules*

*5) After that I modify the axis2.xml*

 <!-- Global Modules  -->
    <!-- ================================================= -->
    <!-- Comment this to disable Addressing -->
    <module ref="addressing"/>
 *   <module ref="TestModule"/>*

 <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="TestPhase"/>*
        <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="OperationInPhase">
            <handler name="MustUnderstandChecker"

 class="org.apache.axis2.jaxws.dispatchers.MustUnderstandChecker">
                <order phase="OperationInPhase"/>
            </handler>
        </phase>
        <phase name="soapmonitorPhase"/>
    </phaseOrder>
    <phaseOrder type="OutFlow">
        <!--      user can add his own phases to this area  -->
        <phase name="soapmonitorPhase"/>
        <phase name="OperationOutPhase"/>
        <!--system predefined phase-->
        <!--these phase will run irrespective of the service-->
        <phase name="RMPhase"/>
        <phase name="PolicyDetermination"/>
        <phase name="MessageOut">
</phase>
        <phase name="Security"/>
        *<phase name="TestPhase"/>*
    </phaseOrder>
    <phaseOrder type="InFaultFlow">
        <phase name="Addressing">
            <handler name="AddressingBasedDispatcher"

 class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
                <order phase="Addressing"/>
            </handler>
        </phase>
        <phase name="Security"/>
*        <phase name="TestPhase"/>*
        <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"/>
        <!--      user can add his own phases to this area  -->
        <phase name="OperationInFaultPhase"/>
        <phase name="soapmonitorPhase"/>

    </phaseOrder>
    <phaseOrder type="OutFaultFlow">
        <!--      user can add his own phases to this area  -->
        <phase name="soapmonitorPhase"/>
        <phase name="OperationOutFaultPhase"/>
        <phase name="RMPhase"/>
        <phase name="PolicyDetermination"/>
        <phase name="MessageOut">
</phase>
        <phase name="Security"/>
      *  <phase name="TestPhase"/>*
    </phaseOrder>

No Idea why I am getting the Exception. Again In my Server code when I am
trying to access The SOAPEnvelope , it is giving the the bellow exception

*MessageContext messageContext = MessageContext.getCurrentMessageContext();*
*SOAPEnvelope soapEnvelope = messageContext.getEnvelope();*

when I am trying to print or access the *soapEnvelope*, it is throwing  the
bellow exception
*com.sun.jdi.InvocationException occurred invoking method.*



The SOAP XML I am sending to server is like bellow Format,

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/
">
    <SOAP-ENV:Header>
        <AuthenticationInfo>
            <userName>ABC</userName>
            <password>ABC</password>
        </AuthenticationInfo>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <EMP>
             <NAME>SATYA</NAME>
              <ROLLNO>1</ROLLNO>
         </EMP>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Please help me and suggest me how to solve this problem. If I did anything
wrong please let me know. Your suggestions are valuable to me.

Thanks,
Satya

Mime
View raw message