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);
    }
  }
Esempio n. 3
0
 public Object invoke(Method method, Object[] args, MessageContext context) throws XFireFault {
   Object serviceObject = getServiceObject(context);
   if (serviceObject instanceof GroovyObject) {
     GroovyObject pogo = (GroovyObject) serviceObject;
     try {
       return pogo.invokeMethod(method.getName(), args);
     } catch (UndeclaredThrowableException e) {
       Throwable t = e.getUndeclaredThrowable();
       throw XFireFault.createFault(t);
     } catch (Exception e) {
       throw new XFireFault(e.getMessage(), e.getCause(), XFireFault.RECEIVER);
     }
   } else {
     return super.invoke(method, args, context);
   }
 }