Hi all, before asking a question regarding the existing API, I'd like to mention the targeted use case (requirement): Detect/count application level faults passed from the service over Synapse to the client independent of the application level protocol (e.g. SOAP/Hessian) used on top of the transport protocol.
While looking for a solution I stumbled over MessageContext.isFaultResponse() The name was promising... ;-) From looking at the Java-Doc I honestly was not sure about the purpose of this operation. So I had a very quick look at the current usage. The corresponding setter is called within the FaultMediator (but there only within makePOXFault(); not within makeSOAPFault()). Is this intended? Anyway it looks like this message context flag is only used if Synapse has created its own fault - not if the application passes back a fault. Is this observation correct? I'm fine with this - I just would like to better understand the existing logic. Internal faults within Synapse (exceptions) are stored within a generic property map within each message context. E.g. using the keys SynapseConstants.ERROR_CODE, SynapseConstants.ERROR_MESSAGE, SynapseConstants.ERROR_DETAIL, SynapseConstants.ERROR_EXCEPTION I'm able to get details about those internal faults. So far as I can see there is currently no convenient way to detect application faults as they are not centrally stored. In fact they depend on the application level protocol used and one has to analyze the message to find this out. So for a SOAP message I have to write code like this: final SOAPFault fault = axis2MessageCtx.getEnvelope().getBody().getFault(); SOAPFaultCode faultcode = fault.getCode(); SOAPFaultReason faultmessage = fault.getReason(); //... In order to detect errors for other protocols, like the binary Hessian protocol, things get even more complicated. At mediation time, I'm rather late to detect those, as I would need access to the binary stream. How to best tackle/support such cases? I guess I'm looking for a mechanism to intercept the message building process. If each application protocol specific (or actually depending on some magic Axis2 logic rather content type specific) message builder were able to detect a fault message and set a custom property in the message context, later at mediation time it would be possible to always ask for the same property (independent of the protocol). Problem: How to do this without rewriting each Builder and registering own MessageBuilders? Any other (better) ideas? Totally wrong approach? Please just don't blame the requirement! ;-) I know that it sounds strange to count faults send from the applications in an infrastructure component... Further it is a requirement to differentiate between faults coming from the service and self generated faults (e.g. we don't find a matching destination and create a fault from the default case of a switch mediator). The custom mediator analyzing the message send out does not know whether it came from the client or was generated using the FaultMediator or can I check this? Regards, Eric
