public CustomFaultHandler() { super(); setPhase(Phase.USER); }
public void invoke(MessageContext context) throws Exception { XFireFault fault = (XFireFault) context.getExchange().getFaultMessage().getBody(); Throwable cause = fault.getCause(); OperationInfo op = null; if (context.getExchange() != null) op = context.getExchange().getOperation(); if (cause == null || op == null) return; FaultInfo faultPart = getFaultForClass(op, cause.getClass()); if (faultPart != null) { handleFault(context, fault, cause, (MessagePartInfo) faultPart.getMessageParts().get(0)); } }
protected void handleFault(MessageContext context, XFireFault fault, Throwable cause, MessagePartInfo faultPart) throws XFireFault { JDOMStreamWriter writer = new JDOMStreamWriter(fault.getDetail()); Object faultBean = getFaultBean(cause, faultPart, context); try { AbstractBinding.writeParameter(writer, context, faultBean, faultPart, faultPart.getName().getNamespaceURI()); } catch (XMLStreamException e) { throw new XFireFault("Could not write to outgoing stream.", e, XFireFault.RECEIVER); } }
protected void registerHandlers(Service service) { service.addInHandler(new ServiceInvocationHandler()); service.addInHandler(new PostInvocationHandler()); service.addOutHandler(new OutMessageSender()); service.addFaultHandler(new FaultSender()); service.addFaultHandler(new CustomFaultHandler()); }