Accessing SOAP fault code and fault message via Axis2/Axiom-API does not work
-----------------------------------------------------------------------------

                 Key: ESBJAVA-522
                 URL: https://wso2.org/jira/browse/ESBJAVA-522
             Project: WSO2 ESB
          Issue Type: Bug
    Affects Versions: 1.7
            Reporter: Eric Hubert
            Assignee: Asankha Perera
            Priority: Blocker


We are using the following code to access SOAP faultcode and faultstring:
 if (axis2MessageCtx.getEnvelope().getBody().getFault() != null) {
    SOAPFault fault = axis2MessageCtx.getEnvelope().getBody().getFault();
    OMElement faultcode = (OMElement) fault.getChildrenWithName(new 
QName("faultcode")).next();
    messagePropertyDTO.setFaultCode(faultcode.getText());
    OMElement faultmessage = (OMElement) fault.getChildrenWithName(new 
QName("faultstring")).next();
    messagePropertyDTO.setFault(faultmessage.getText());
}
it works with WSO2 ESB 1.7 Beta-2. In the proposed final version we get the 
following exception:
2008-06-09 10:20:24,261 [127.0.0.1-berjbolle-lx1] [HttpServerWorker-1]  INFO 
TimeoutHandler This engine will expire all callbacks after : 86400 seconds, 
irrespective of the timeout action, after the specified or optional timeout 
Exception in thread "HttpClientWorker-1" org.apache.axiom.om.OMException: 
java.util.NoSuchElementException
        at 
org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:249)
        at 
org.apache.axiom.om.impl.llom.OMElementImpl.buildNext(OMElementImpl.java:633)
        at 
org.apache.axiom.om.impl.llom.OMElementImpl.getFirstOMChild(OMElementImpl.java:650)
        at 
org.apache.axiom.om.impl.llom.OMElementImpl.getChildrenWithName(OMElementImpl.java:217)
        at 
de.jamba.soa.esb.wso2.mediator.jtrace.JTraceMediator.setResponseProperties(JTraceMediator.java:130)
        at 
de.jamba.soa.esb.wso2.mediator.jtrace.JTraceMediator.mediate(JTraceMediator.java:65)
        at 
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:58)
        at 
org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:125)
        at 
org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:174)
        at 
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:58)
        at 
org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:125)
        at 
org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:162)
        at 
org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:301)
        at 
org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:131)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)
        at 
org.apache.synapse.transport.nhttp.ClientWorker.run(ClientWorker.java:200)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.util.NoSuchElementException
        at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1083)
        at 
org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:506)
        at 
org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:161)
        ... 18 more

One other problem we noticed on the way is a strange behaviour of 
getChildrenWithLocalName(). If we changed the above code in 1.7 Beta 2 to this:
 if (axis2MessageCtx.getEnvelope().getBody().getFault() != null) {
    SOAPFault fault = axis2MessageCtx.getEnvelope().getBody().getFault();
    OMElement faultcode = (OMElement) 
fault.getChildrenWithName("faultcode").next();
    messagePropertyDTO.setFaultCode(faultcode.getText());
    OMElement faultmessage = (OMElement) 
fault.getChildrenWithName("faultstring").next();
    messagePropertyDTO.setFault(faultmessage.getText());
}

getChildrenWithName() always returned the first Element. No matter of the 
specified string. It could also be "abc" which was not present. I would also 
consider this to be a bug.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://wso2.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

_______________________________________________
Esb-java-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev

Reply via email to