Package org.apache.servicemix.client

Examples of org.apache.servicemix.client.DefaultServiceMixClient.sendSync()


        // Test
        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
        InOut me = client.createInOutExchange();
        me.setService(new QName("http://test", "MyProviderService"));
        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();
View Full Code Here


        RobustInOnly in = client.createRobustInOnlyExchange();
        in.setInterfaceName(new QName("http://http.servicemix.org/Test", "ProviderInterface"));
        in.getInMessage().setContent(new StreamSource(new ByteArrayInputStream(msg.getBytes())));

        long t0 = System.currentTimeMillis();
        client.sendSync(in);
        long t1 = System.currentTimeMillis();
        assertTrue(in.getStatus() == ExchangeStatus.DONE);

        // Check we received the message
        receiver.getMessageList().assertMessagesReceived(1);
View Full Code Here

        in.setInterfaceName(new QName("http://http.servicemix.org/Test", "ProviderInterface"));
        in.getInMessage().setContent(new StreamSource(new ByteArrayInputStream(msg.getBytes())));
        in.getInMessage().setProperty(JbiConstants.HTTP_DESTINATION_URI, "http://localhost:9192/CheckAvailability");

        long t0 = System.currentTimeMillis();
        client.sendSync(in);
        long t1 = System.currentTimeMillis();
        assertTrue(in.getStatus() == ExchangeStatus.DONE);

        // Check we received the message
        receiver.getMessageList().assertMessagesReceived(1);
View Full Code Here

        InOut inout = client.createInOutExchange();
        inout.setInterfaceName(new QName("http://http.servicemix.org/Test", "ProviderInterface"));
        inout.getInMessage().setContent(new StreamSource(new ByteArrayInputStream(msg.getBytes())));

        long t0 = System.currentTimeMillis();
        client.sendSync(inout);
        long t1 = System.currentTimeMillis();
        assertTrue(inout.getStatus() == ExchangeStatus.ACTIVE);

        // Check we received the message
        assertNotNull(inout.getOutMessage());
View Full Code Here

        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
        InOut me = client.createInOutExchange();
        me.setService(new QName("http://test", "MyProviderService"));
        InputStream fis = getClass().getResourceAsStream("addressing-request.xml");
        me.getInMessage().setContent(new StreamSource(fis));
        client.sendSync(me);
        if (me.getStatus() == ExchangeStatus.ERROR) {
            if (me.getError() != null) {
                throw me.getError();
            } else {
                fail("Received ERROR status");
View Full Code Here

        me.getInMessage().setContent(new StringSource(
                "<echo xmlns:xop='http://www.w3.org/2004/08/xop/include'><msg>"
                + "hello world</msg><binary><xop:Include href='binary'/></binary></echo>"));
        me.getInMessage().addAttachment("binary", new DataHandler(
                new ByteArrayDataSource(new byte[] {0, 1, 2}, "image/jpg")));
        client.sendSync(me);
        assertNotNull(me.getOutMessage());
        assertEquals(1, me.getOutMessage().getAttachmentNames().size());
        DataHandler dh = me.getOutMessage().getAttachment(
                (String) me.getOutMessage().getAttachmentNames().iterator().next());
        assertNotNull(dh);
View Full Code Here

        assertNotNull("We should find a service endpoint!", se);

        InOnly exchange = client.createInOnlyExchange();
        exchange.setEndpoint(se);
        exchange.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(exchange);

        assertExchangeWorked(exchange);

        ListenerBean bean = (ListenerBean) getBean("listenerBean");
        MessageExchange answer = bean.getLastExchange();
View Full Code Here

        assertNotNull("We should find a service endpoint!", se);

        InOut exchange = client.createInOutExchange();
        exchange.setEndpoint(se);
        exchange.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(exchange);
        client.done(exchange);

        assertExchangeWorked(exchange);

        ListenerBean bean = (ListenerBean) getBean("listenerBean");
View Full Code Here

       
        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
        InOut me = client.createInOutExchange(new QName("http://test", "Echo"), null, null);
        me.setInMessage(me.createMessage());
        me.getInMessage().setContent(new StringSource("<echo xmlns='http://test'><msg>world</msg></echo>"));
        client.sendSync(me);
        assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
        assertNotNull(me.getOutMessage());
        client.done(me);
    }
   
View Full Code Here

        Destination d = client.createDestination("service:urn:test:s0");
        InOut me = d.createInOutExchange();
        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
       
        tm.begin();
        boolean ok = client.sendSync(me);
        assertTrue(ok);
        client.done(me);
        tm.commit();
    }
   
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.