"In" MessageContext.envelope is overwritten by "Fault" MessageContext.envelope on Exception -------------------------------------------------------------------------------------------
Key: AXIS2-2850 URL: https://issues.apache.org/jira/browse/AXIS2-2850 Project: Axis 2.0 (Axis2) Issue Type: Bug Components: kernel Affects Versions: 1.2 Environment: Axis2 1.2, Tomcat 5.5. Reporter: Kevin Priority: Blocker To reproduce: - Use wsdl2java to create a web service - create a custom handler extending AbstractHandler - Add a <phase> entry in the axis.xml to execute the handler PostDispatch - In the web service skeleton class, implement the service by throwing the declared exception. The exception should cause the fault message defined in the wsdl to be returned in the SOAP response - run a test on the web service - When the custom handler is invoked, attempt to retrieve the "In" soap envelope using msgContext.getOperationContext().getMessageContext("In").getEnvelope() - the "In" envelope is the "Fault" envelope, but it should be the original incoming soap message envelope. Note that if the exception is not thrown in the skeleton class, the "In" envelope is the correct value. As far as I can see, the offending code is: AxisServlet.handleFault() line 368: 366 : saminda 509437 MessageContext faultContext = 367 : MessageContextBuilder.createFaultMessageContext(msgContext, e); 368 : saminda 509952 msgContext.setEnvelope(faultContext.getEnvelope()); from Eran Chinthaka <[EMAIL PROTECTED]> reply-to [EMAIL PROTECTED] to [EMAIL PROTECTED] date Jun 24, 2007 12:44 AM subject Re: [Axis2] Accessing SOAP message from MessageContexts in Handlers mailed-by ws.apache.org -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This seems to be a bug for me. Can you please create a JIRA giving enough information to re-create this problem. Also please mark the issue as a blocker as I think this should be fixed before the next release. Thanks, Chinthaka Kevin TierOne wrote: > Hi Wayne, > > We've talked about this but I thought I'd post to see if anyone else can > give us insight. > > > The original message context of the > MySoapReceiverInOut.invokeBusinessLogic() code stores the incoming soap > envelope. If your skeleton throws an exception, AxisFault.handleFault() > will replace the messageContext's soap envelope with > faultContext.getEnvelope(). If there is no exception in your code, the > setEnvelope() call is not invoked. > > > The reason why you cannot use > msgContext.getOperationContext().getMessageContext("In") to get the > orignal envelope, is that the getMessage("In") refers to the original > message context (because the hashmap stores a reference to original > message context). Its envelope was overwritten with the fault envelope > during the fault handling. Not sure why there is also a > getMessage("Fault") that returns the same envelope. Perhaps it's a bug > or maybe there is a reason for this. I don't know enough about the > Axis2 code. > > > Kevin > > ------------------------------------------------------------------------ > From: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > Subject: Accessing SOAP message from MessageContexts in Handlers > Date: Wed, 20 Jun 2007 16:09:20 -0400 > > > Using Axis2 1.2. Is there a way to read the original SOAP message > within a PostDispatch Handler? > > I'm invoking a custom handler in the PostDispatch phase. The > handler reads the uses the MessageContext to get the original soap > request message. Something like this: > > String > > incomingMsg=msgContext.getOperationContext().getMessageContext("In").getEnvelope().toString(); > System.out.println("Original SOAPMessage: "+incomingMsg); > > This works fine in the success case. The problem is if the Skeleton > code throws an exception, the above code prints the "Fault" soap > message. For example, the following code prints exactly the same > output: > > String > > incomingMsg=3DmsgContext.getOperationContext().getMessageContext("In").getEnvelope().toString(); > System.out.println("SOAPMessage: "+incomingMsg);=0A= > > String > > faultMsg=3DmsgContext.getOperationContext().getMessageContext("Fault").getEnvelope().toString(); > System.out.println("SOAPMessage: "+faultMsg); > > Am I doing something incorrectly? Is there another way to get the > original SOAP message in a Handler? > > Thanks, > Wayne > -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]