Package javax.jbi.messaging

Examples of javax.jbi.messaging.Fault


          // As we expect a DOMResult as output, we must ensure that the input is a
          // DOMSource
          DOMSource src = sourceTransformer.toDOMSource(out.getContent());
          doValidation(validator,src,result);
            if (errorHandler.hasErrors()) {
                Fault fault = exchange.createFault();
               
                // set the schema and source document as properties on the fault
                fault.setProperty("org.apache.servicemix.schema", schema);
                fault.setProperty("org.apache.servicemix.xml", src);
               
                /*
                 * check if this error handler supports the capturing of
                 * error messages.
                 */
                if (errorHandler.capturesMessages()) {

                  /*
                   * In descending order of preference select a format to use. If
                   * neither DOMSource, StringSource or String are supported throw
                   * a messaging exception.
                   */
                  if (errorHandler.supportsMessageFormat(DOMSource.class)) {
                    fault.setContent(
                        (DOMSource)errorHandler.getMessagesAs(DOMSource.class));
                  } else if (errorHandler.supportsMessageFormat(StringSource.class)) {
                    fault.setContent(sourceTransformer.toDOMSource(
                        (StringSource)errorHandler.getMessagesAs(StringSource.class)));
                  } else if (errorHandler.supportsMessageFormat(String.class)) {
                    fault.setContent(
                        sourceTransformer.toDOMSource(
                            new StringSource(
                                (String)errorHandler.getMessagesAs(String.class))));
                  } else {
                    throw new MessagingException("MessageAwareErrorHandler implementation " +
                        errorHandler.getClass().getName() +
                        " does not support a compatible error message format.");
                  }
                } else {
                  /*
                   * we can't do much here if the ErrorHandler implementation does
                   * not support capturing messages
                   */
                    fault.setContent(new DOMSource(result.getNode(), result.getSystemId()));
                }
                throw new FaultException("Failed to validate against schema: " + schema, exchange, fault);
            }
            else {
              // Retrieve the ouput of the validation
View Full Code Here


            if (ssn == null || ssn.length() == 0) {
                fail(exchange, new NullPointerException());
                return;
            }
            if (!ssn.startsWith("1")) {
                Fault fault = inOut.createFault();
                fault.setContent(new StringSource("<InvalidSSN xmlns=\"urn:logicblaze:soa:creditagency\"><ssn>" + ssn + "</ssn></InvalidSSN>"));
                fail(inOut, fault);
            } else {
                String operation = null;
                if (inOut.getOperation() != null) {
                    operation = inOut.getOperation().getLocalPart();
View Full Code Here

        if (tme.getStatus() == ExchangeStatus.DONE) {
            done(exchange);
        } else if (tme.getStatus() == ExchangeStatus.ERROR) {
            fail(exchange, tme.getError());
        } else if (tme.getFault() != null) {
            Fault fault = MessageUtil.copyFault(tme);
            done(tme);
            MessageUtil.transferToFault(fault, exchange);
            sendSync(exchange);
        } else if (tme.getMessage("out") != null) {
            NormalizedMessage out = MessageUtil.copyOut(tme);
View Full Code Here

                // So just transform it to a string and send an error
                String fault = new SourceTransformer().contentToString(tme.getFault());
                done(tme);
                fail(exchange, new FaultException(fault, null, null));
            } else {
                Fault fault = MessageUtil.copyFault(tme);
                MessageUtil.transferToFault(fault, exchange);
                done(tme);
                sendSync(exchange);
            }
        }
        // This should not happen
        else if (tme.getOutMessage() == null) {
            throw new IllegalStateException("Exchange status is " + ExchangeStatus.ACTIVE + " but has no correlation set");
        }
        // This is the answer from the transformer
        MessageExchange me = exchangeFactory.createExchange(exchange.getPattern());
        target.configureTarget(me, getContext());
        MessageUtil.transferOutToIn(tme, me);
        sendSync(me);
        done(tme);
        if (me.getStatus() == ExchangeStatus.DONE) {
            done(exchange);
        } else if (me.getStatus() == ExchangeStatus.ERROR) {
            fail(exchange, me.getError());
        } else if (me.getFault() != null) {
            if (exchange instanceof InOnly) {
                // Do not use the fault has it may contain streams
                // So just transform it to a string and send an error
                String fault = new SourceTransformer().contentToString(me.getFault());
                done(me);
                fail(exchange, new FaultException(fault, null, null));
            } else {
                Fault fault = MessageUtil.copyFault(me);
                MessageUtil.transferToFault(fault, exchange);
                done(me);
                sendSync(exchange);
            }
        } else {
View Full Code Here

                    Header contentType = method.getResponseHeader(Constants.HEADER_CONTENT_TYPE);
                    soapMessage = reader.read(method.getResponseBodyAsStream(),
                                              contentType != null ? contentType.getValue() : null);
                    context.setFaultMessage(soapMessage);
                    soapHelper.onAnswer(context);
                    Fault fault = exchange.createFault();
                    fault.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(method));
                    soapHelper.getJBIMarshaler().toNMS(fault, soapMessage);
                    exchange.setFault(fault);
                    if (txSync) {
                        channel.sendSync(exchange);
                    } else {
View Full Code Here

                throw new IllegalStateException("Exchange status is " + ExchangeStatus.DONE);
            } else if (me.getStatus() == ExchangeStatus.ERROR) {
                fail(exchange, me.getError());
                return;
            } else if (me.getFault() != null) {
                Fault fault = MessageUtil.copyFault(me);
                MessageUtil.transferToFault(fault, exchange);
                done(me);
                sendSync(exchange);
                return;
            } else if (me.getOutMessage() == null) {
View Full Code Here

    }

    public void testSoapFault12() throws Exception {
        TransformComponentSupport echo = new TransformComponentSupport() {
            protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws MessagingException {
                Fault f = exchange.createFault();
                f.setContent(new StringSource("<hello xmlns='myuri'>this is a fault</hello>"));
                f.setProperty(JBIMarshaler.SOAP_FAULT_REASON, "My reason");
                throw new FaultException(null, exchange, f);
            }
        };
        echo.setService(new QName("urn:test", "echo"));
        echo.setEndpoint("echo");
View Full Code Here

    }
   
    public void testSoapFault11() throws Exception {
        TransformComponentSupport echo = new TransformComponentSupport() {
            protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws MessagingException {
                Fault f = exchange.createFault();
                f.setContent(new StringSource("<hello xmlns='myuri'>this is a fault</hello>"));
                f.setProperty(JBIMarshaler.SOAP_FAULT_REASON, "My reason");
                throw new FaultException(null, exchange, f);
            }
        };
        echo.setService(new QName("urn:test", "echo"));
        echo.setEndpoint("echo");
View Full Code Here

        c.close();
       
        // Set response or DONE status
        if (isInAndOut(exchange)) {
            if (ctx.getExchange().hasFaultMessage() && ctx.getExchange().getFaultMessage().getBody() != null) {
                Fault fault = exchange.createFault();
                fault.setContent(new StringSource(out.toString()));
                exchange.setFault(fault);
            } else {
                NormalizedMessage outMsg = exchange.createMessage();
                outMsg.setContent(new StringSource(out.toString()));
                exchange.setMessage(outMsg, "out");
View Full Code Here

                if (me.getStatus() == ExchangeStatus.ERROR && reportErrors) {
                    fail(exchange, me.getError());
                } else if (me.getStatus() == ExchangeStatus.DONE) {
                    done(exchange);
                } else if (me.getFault() != null && reportErrors) {
                    Fault fault = MessageUtil.copyFault(me);
                    done(me);
                    MessageUtil.transferToFault(fault, exchange);
                    sendSync(exchange);
                }
            } else {
View Full Code Here

TOP

Related Classes of javax.jbi.messaging.Fault

Copyright © 2018 www.massapicom. 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.