Package javax.jbi.messaging

Examples of javax.jbi.messaging.InOut


        jbi.activateComponent(echo, "echo");

        jbi.start();

        ServiceMixClient client = new DefaultServiceMixClient(jbi);
        InOut me = client.createInOutExchange();
        me.setService(new QName("bean"));
        me.setOperation(new QName("receive"));
        NormalizedMessage nm = me.getInMessage();
        nm.setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(me);
        assertExchangeWorked(me);
        client.done(me);
    }
View Full Code Here


        setService(new QName("urn:logicblaze:soa:creditagency", "CreditAgencyService"));
        setEndpoint("agency");
    }
   
    public void onMessageExchange(MessageExchange exchange) throws MessagingException {
        InOut inOut = (InOut) exchange;
        if (inOut.getStatus() == ExchangeStatus.DONE) {
            return;
        } else if (inOut.getStatus() == ExchangeStatus.ERROR) {
            return;
        }
        try {
            Document doc = (Document) new SourceTransformer().toDOMNode(inOut.getInMessage());
            String ssn = textValueOfXPath(doc, "//*[local-name()='ssn']");
            if (ssn == null || ssn.length() == 0) {
                fail(exchange, new NullPointerException());
                return;
            }
            if (!ssn.startsWith("1")) {
                Fault fault = inOut.createFault();
                fault.setContent(new StringSource(
                        "<invalidSSNFault xmlns=\"urn:logicblaze:soa:creditagency:types\"><ssn>"
                        + ssn + "</ssn></invalidSSNFault>"));
                fail(inOut, fault);
            } else {
                String operation = null;
                if (inOut.getOperation() != null) {
                    operation = inOut.getOperation().getLocalPart();
                } else {
                    operation = doc.getDocumentElement().getLocalName();
                }
                String output;
                if ("getCreditScore".equals(operation)) {
                    output = "<getCreditScoreResponse xmlns=\"urn:logicblaze:soa:creditagency\"><score>"
                        + getCreditScore(ssn) + "</score></getCreditScoreResponse>";
                } else if ("getCreditHistoryLength".equals(operation)) {
                    output = "<getCreditHistoryLengthResponse xmlns=\"urn:logicblaze:soa:creditagency\"><length>"
                        + getCreditHistoryLength(ssn) + "</length></getCreditHistoryLengthResponse>";
                } else {
                    throw new UnsupportedOperationException(operation);
                }
                NormalizedMessage answer = inOut.createMessage();
                answer.setContent(new StringSource(output));
                answer(inOut, answer);
            }
        } catch (Exception e) {
            throw new MessagingException(e);
View Full Code Here

    private static Log logger =  LogFactory.getLog(Jsr181ComponentTest.class);

    public void test() throws Exception {
        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
        InOut me = client.createInOutExchange();
        me.setInterfaceName(new QName("http://test", "EchoPortType"));
        me.getInMessage().setContent(new StringSource("<echo xmlns='http://test'><echoin0>world</echoin0></echo>"));
        client.sendSync(me);
        if (me.getStatus() == ExchangeStatus.ERROR) {
            if (me.getFault() != null) {
                fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
            } else if (me.getError() != null) {
                throw me.getError();
            } else {
                fail("Received ERROR status");
            }
        } else {
            logger.info(new SourceTransformer().toString(me.getOutMessage().getContent()));
        }
    }
View Full Code Here

        assertNotNull(EchoService.getInstance());
        assertNotNull(EchoService.getInstance().getContext());
       
        // Call it
        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
        InOut me = client.createInOutExchange();
        me.setInterfaceName(new QName("http://test", "EchoServicePortType"));
        me.getInMessage().setContent(new StringSource("<echo xmlns='http://test'><in0>world</in0></echo>"));
        client.sendSync(me);
        if (me.getStatus() == ExchangeStatus.ERROR) {
            if (me.getFault() != null) {
                fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
            } else if (me.getError() != null) {
                throw me.getError();
            } else {
                fail("Received ERROR status");
            }
        } else {
            logger.info(new SourceTransformer().toString(me.getOutMessage().getContent()));
        }
    }
View Full Code Here

        assertNotNull(EchoService.getInstance());
        assertNotNull(EchoService.getInstance().getContext());
       
        // Call it
        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
        InOut me = client.createInOutExchange();
        me.setInterfaceName(new QName("http://test", "EchoService2PortType"));
        me.getInMessage().setContent(new StringSource("<echo xmlns='http://test'><in0>world</in0></echo>"));
        client.sendSync(me);
        if (me.getStatus() == ExchangeStatus.ERROR) {
            if (me.getFault() != null) {
                fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
            } else if (me.getError() != null) {
                throw me.getError();
            } else {
                fail("Received ERROR status");
            }
        } else {
            logger.info(new SourceTransformer().toString(me.getOutMessage().getContent()));
        }
    }
View Full Code Here

        jbi.activateComponent(echo2, "echo2");

        jbi.start();

        ServiceMixClient client = new DefaultServiceMixClient(jbi);
        InOut me = client.createInOutExchange();
        me.setService(new QName("bean"));
        me.setOperation(new QName("receive"));
        NormalizedMessage nm = me.getInMessage();
        nm.setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(me);
        assertExchangeWorked(me);
        client.done(me);
    }
View Full Code Here

        container.start();

        ServiceMixClient client = new DefaultServiceMixClient(container);
        Destination dest = client.createDestination("service:urn:test:s2");
        InOut me = dest.createInOutExchange();
        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(me);
        assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
        String str = new SourceTransformer().contentToString(me.getOutMessage());
        client.done(me);
        logger.info(str);
    }
View Full Code Here

        container.start();

        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
        Destination d = client.createDestination("service:urn:test:s0");
        InOut me = d.createInOutExchange();
        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        File f = new File(getClass().getResource("servicemix.jpg").getFile());
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        FileUtil.copyInputStream(new FileInputStream(f), baos);
        DataSource ds = new ByteArrayDataSource(baos.toByteArray(), "image/jpeg");
        DataHandler dh = new DataHandler(ds);
        me.getInMessage().addAttachment("image", dh);
        client.sendSync(me);
        assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
        assertEquals(1, me.getOutMessage().getAttachmentNames().size());
        client.done(me);
    }
View Full Code Here

        container.activateComponent(receiver, "Receiver");
       
        container.start();

        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
        InOut me = client.createInOutExchange();
        me.setInterfaceName(new QName("http://jsr181.servicemix.apache.org", "ComplexPojoPortType"));
        me.getInMessage().setContent(new StringSource(
                "<oneWay xmlns='http://jsr181.servicemix.apache.org'><in0>world</in0></oneWay>"));
        client.sendSync(me);
       
        // Wait all acks being processed
        Thread.sleep(100);
View Full Code Here

        container.activateComponent(as);
       
        container.start();

        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
        InOut me = client.createInOutExchange();
        me.setInterfaceName(new QName("http://jsr181.servicemix.apache.org", "ComplexPojoPortType"));
        me.getInMessage().setContent(new StringSource(
                "<twoWay xmlns='http://jsr181.servicemix.apache.org'><in0>world �</in0></twoWay>"));
        client.sendSync(me);
        log.info(new SourceTransformer().contentToString(me.getOutMessage()));
        client.done(me);
       
        // Wait all acks being processed
        Thread.sleep(100);
    }
View Full Code Here

TOP

Related Classes of javax.jbi.messaging.InOut

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.