Examples of XFireFault


Examples of org.codehaus.xfire.fault.XFireFault

                    }
                    if (me.getStatus() == ExchangeStatus.ERROR) {
                        me.setStatus(ExchangeStatus.DONE);
                        channel.send(me);
                        if (me.getError() != null) {
                            throw new XFireFault(me.getError(), XFireFault.RECEIVER);
                        } else if (me.getFault() != null){
                            // TODO: retrieve fault
                            throw new XFireFault("Fault received", XFireFault.RECEIVER);
                        } else {
                            throw new XFireFault("Unkown Error", XFireFault.RECEIVER);
                        }
                    }
                    Source outSrc = me.getOutMessage().getContent();
                    me.setStatus(ExchangeStatus.DONE);
                    channel.send(me);
View Full Code Here

Examples of org.codehaus.xfire.fault.XFireFault

                if (!channel.sendSync(me)) {
                    throw new XFireException("Unable to send jbi exchange: sendSync returned false");
                }
                if (me.getStatus() == ExchangeStatus.ERROR) {
                    if (me.getError() != null) {
                        throw new XFireFault(me.getError(), XFireFault.RECEIVER);
                    } else {
                        throw new XFireFault("Unkown Error", XFireFault.RECEIVER);
                    }
                } else if (me.getStatus() == ExchangeStatus.ACTIVE) {
                    if (me.getFault() != null) {
                        JDOMResult result = new JDOMResult();
                        String str = getTransformer().contentToString(me.getFault());
                        getTransformer().toResult(new StringSource(str), result);
                        Element e = result.getDocument().getRootElement();
                        e = (Element) e.clone();
                        me.setStatus(ExchangeStatus.DONE);
                        channel.send(me);
                        XFireFault xfireFault = new XFireFault(str, XFireFault.RECEIVER);
                        xfireFault.getDetail().addContent(e);
                        throw xfireFault;
                    } else if (me.getMessage("out") != null) {
                        Source outSrc = me.getMessage("out").getContent();
                        InMessage inMessage = new InMessage(getTransformer().toXMLStreamReader(outSrc), getUri());
                        getEndpoint().onReceive(context, inMessage);
View Full Code Here

Examples of org.codehaus.xfire.fault.XFireFault

        controller.doService(request, response);
    }

    public void invokeInOnly(Source source, MessageContext context) throws XFireFault {
        if (source == null) {
            throw new XFireFault("Invalid source.", XFireFault.SENDER);
        }
        try {
          if (soapAction != null) {
            XFireServletController.getResponse().setHeader("SOAPAction", soapAction);
          }
            DeliveryChannel channel = getDeliveryChannel();
            MessageExchangeFactory factory = channel.createExchangeFactory();
            InOnly exchange = factory.createInOnlyExchange();
            populateExchange(exchange, source, context);
            boolean result = channel.sendSync(exchange);
            if (!result) {
                throw new XFireFault("Error sending exchange", XFireFault.SENDER);
            }
        } catch (XFireFault e) {
            throw e;
        } catch (Exception e) {
            throw new XFireFault(e);
        }
    }
View Full Code Here

Examples of org.codehaus.xfire.fault.XFireFault

        }
    }
   
    public Source invokeInOut(Source source, MessageContext context) throws XFireFault {
        if (source == null) {
            throw new XFireFault("Invalid source.", XFireFault.SENDER);
        }
        try {
          if (soapAction != null) {
            XFireServletController.getResponse().setHeader("SOAPAction", soapAction);
          }
            DeliveryChannel channel = getDeliveryChannel();
            MessageExchangeFactory factory = channel.createExchangeFactory();
            InOut exchange = factory.createInOutExchange();
            populateExchange(exchange, source, context);
            boolean result = channel.sendSync(exchange);
            if (!result) {
                throw new XFireFault("Error sending exchange", XFireFault.SENDER);
            }
            if (exchange.getStatus() == ExchangeStatus.ERROR) {
                Exception e = exchange.getError();
                if (e == null) {
                    throw new XFireFault("Received error", XFireFault.SENDER);
                } else {
                    throw new XFireFault(e, XFireFault.SENDER);
                }
            }
            NormalizedMessage outMessage = exchange.getOutMessage();
            if (outMessage == null) {
                exchange.setError(new Exception("Expected an out message"));
                channel.sendSync(exchange);
                throw new XFireFault("No response", XFireFault.SENDER);
            }                   
            Source src = exchange.getOutMessage().getContent();
            exchange.setStatus(ExchangeStatus.DONE);
            channel.send(exchange);
            src = transformer.toDOMSource(src);
            return src;
        } catch (XFireFault e) {
            throw e;
        } catch (Exception e) {
            throw new XFireFault(e);
    }
    }
View Full Code Here

Examples of org.codehaus.xfire.fault.XFireFault

        controller.doService(request, response);
    }

    public void invokeInOnly(Source source, MessageContext context) throws XFireFault {
        if (source == null) {
            throw new XFireFault("Invalid source.", XFireFault.SENDER);
        }
        try {
          if (soapAction != null) {
            XFireServletController.getResponse().setHeader("SOAPAction", soapAction);
          }
            DeliveryChannel channel = getDeliveryChannel();
            MessageExchangeFactory factory = channel.createExchangeFactory();
            InOnly exchange = factory.createInOnlyExchange();
            populateExchange(exchange, source, context);
            boolean result = channel.sendSync(exchange);
            if (!result) {
                throw new XFireFault("Error sending exchange", XFireFault.SENDER);
            }
        } catch (XFireFault e) {
            throw e;
        } catch (Exception e) {
            throw new XFireFault(e);
        }
    }
View Full Code Here

Examples of org.codehaus.xfire.fault.XFireFault

        }
    }
   
    public Source invokeInOut(Source source, MessageContext context) throws XFireFault {
        if (source == null) {
            throw new XFireFault("Invalid source.", XFireFault.SENDER);
        }
        try {
          if (soapAction != null) {
            XFireServletController.getResponse().setHeader("SOAPAction", soapAction);
          }
            DeliveryChannel channel = getDeliveryChannel();
            MessageExchangeFactory factory = channel.createExchangeFactory();
            InOut exchange = factory.createInOutExchange();
            populateExchange(exchange, source, context);
            boolean result = channel.sendSync(exchange);
            if (!result) {
                throw new XFireFault("Error sending exchange", XFireFault.SENDER);
            }
            if (exchange.getStatus() == ExchangeStatus.ERROR) {
                Exception e = exchange.getError();
                if (e == null) {
                    throw new XFireFault("Received error", XFireFault.SENDER);
                } else {
                    throw new XFireFault(e, XFireFault.SENDER);
                }
            }
            NormalizedMessage outMessage = exchange.getOutMessage();
            if (outMessage == null) {
                exchange.setError(new Exception("Expected an out message"));
                channel.sendSync(exchange);
                throw new XFireFault("No response", XFireFault.SENDER);
            }                   
            Source src = exchange.getOutMessage().getContent();
            exchange.setStatus(ExchangeStatus.DONE);
            channel.send(exchange);
            src = transformer.toDOMSource(src);
            return src;
        } catch (XFireFault e) {
            throw e;
        } catch (Exception e) {
            throw new XFireFault(e);
    }
    }
View Full Code Here

Examples of org.codehaus.xfire.fault.XFireFault

                if (fault == null) {
                    fault = exchange.createFault();
                    exchange.setFault(fault);
                }
                fault.setContent(new StringSource(out.toString(charSet)));
                XFireFault xFault = (XFireFault) ctx.getExchange().getFaultMessage().getBody();
                fault.setProperty(SOAP_FAULT_CODE, xFault.getFaultCode());
                fault.setProperty(SOAP_FAULT_REASON, xFault.getReason());
                fault.setProperty(SOAP_FAULT_ROLE, xFault.getRole());
                fault.setProperty(SOAP_FAULT_SUBCODE, xFault.getSubCode());
            } else {
                String charSet = ctx.getOutMessage().getEncoding();
                NormalizedMessage outMsg = exchange.getMessage("out");
                if (outMsg == null) {
                    outMsg = exchange.createMessage();
View Full Code Here

Examples of org.codehaus.xfire.fault.XFireFault

        protected Exception translateException(Method method, Exception t) {
            if (t instanceof XFireFault == false) {
                logger.debug("Exception is not an XFireFault");
                return t;
            }
            XFireFault xfireFault = (XFireFault) t;
            if (!xfireFault.hasDetails()) {
                logger.debug("XFireFault has no details");
                return t;
            }
            // Get first child element of <detail/>
            List details = xfireFault.getDetail().getContent();
            Element detail = null;
            for (Object o : details) {
                if (o instanceof Element) {
                    detail = (Element) o;
                    break;
                }
            }
            if (detail == null) {
                logger.debug("XFireFault has no element in <detail/>");
                return t;
            }
            QName qname = new QName(detail.getNamespaceURI(),
                                    detail.getName());
            Class<?>[] exceptions = method.getExceptionTypes();
            for (int i = 0; i < exceptions.length; i++) {
                logger.debug("Checking exception: " + exceptions[i]);
                WebFault wf = exceptions[i].getAnnotation(WebFault.class);
                if (wf == null) {
                    logger.debug("No WebFault annotation");
                    continue;
                }
                QName exceptionName = new QName(wf.targetNamespace(), wf.name());
                if (exceptionName.equals(qname)) {
                    try {
                        Method mth = exceptions[i].getMethod("getFaultInfo");
                        Class<?> infoClass = mth.getReturnType();
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(baos);
                        new StaxSerializer().writeElement(detail, writer);
                        writer.close();
                        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
                        JAXBElement<?> obj = JAXBContext.newInstance(infoClass).createUnmarshaller().unmarshal(new StreamSource(bais), infoClass);
                        Constructor<?> cst = exceptions[i].getConstructor(String.class, infoClass);
                        Exception e = (Exception) cst.newInstance(xfireFault.toString(), obj.getValue());
                        return e;
                    } catch (Throwable e) {
                        logger.debug("Error: " + e);
                    }
                } else {
View Full Code Here

Examples of org.codehaus.xfire.fault.XFireFault

    {
        List list = root.getChildren(tagName,wsa);
        if( list!= null ){
            if(list.size()> 1){
               
                XFireFault fault = new XFireFault("Invalid header",new QName(wsa.getURI(),"Sender"));
                fault.addNamespace("wsa",wsa.getURI());
                fault.setSubCode(new QName(wsa.getURI(),"InvalidAddressingHeader"));
                Element detail = new Element("ProblemHeaderQName",wsa);
                detail.addContent(tagName);
                fault.setDetail(detail);
                throw fault;
            }
        }
       
    }
View Full Code Here

Examples of org.codehaus.xfire.fault.XFireFault

                        }
                    }
                   
                    if (aop == null)
                    {
                        throw new XFireFault("Action '" + headers.getAction() + "' was not found for service "
                                + headers.getTo(), XFireFault.SENDER);
                    }

                    MessageExchange exchange = context.getExchange();
                    exchange.setOperation(aop.getOperationInfo());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.