Search in sources :

Example 1 with JaxbDataFormat

use of org.apache.camel.model.dataformat.JaxbDataFormat in project camel by apache.

the class ConsumerMarshallingRouteTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            JaxbDataFormat jaxb = new JaxbDataFormat(false);
            jaxb.setContextPath("org.apache.camel.component.spring.ws.jaxb");
            // request webservice
            from("direct:webservice-marshall").marshal(jaxb).to("spring-ws:http://localhost/?soapAction=http://www.stockquotes.edu/GetQuote&webServiceTemplate=#webServiceTemplate").convertBodyTo(String.class);
            // request webservice
            from("direct:webservice-marshall-unmarshall").marshal(jaxb).to("spring-ws:http://localhost/?soapAction=http://www.stockquotes.edu/GetQuote&webServiceTemplate=#webServiceTemplate").unmarshal(jaxb);
            // provide web service
            from("spring-ws:soapaction:http://www.stockquotes.edu/GetQuote?endpointMapping=#endpointMapping").process(new StockQuoteResponseProcessor());
            // request webservice
            from("direct:webservice-marshall-asinonly").marshal(jaxb).to("spring-ws:http://localhost/?soapAction=http://www.stockquotes.edu/GetQuoteAsInOnly&webServiceTemplate=#webServiceTemplate").convertBodyTo(String.class);
            // provide web service
            from("spring-ws:soapaction:http://www.stockquotes.edu/GetQuoteAsInOnly?endpointMapping=#endpointMapping").setExchangePattern(ExchangePattern.InOnly).process(new StockQuoteResponseProcessor());
            // request webservice
            from("direct:webservice-marshall-asin").marshal(jaxb).to("spring-ws:http://localhost/?soapAction=http://www.stockquotes.edu/GetQuoteAsIn&webServiceTemplate=#webServiceTemplate").convertBodyTo(String.class);
            // provide web service
            from("spring-ws:soapaction:http://www.stockquotes.edu/GetQuoteAsIn?endpointMapping=#endpointMapping").setHeader("setin", constant("true")).process(new StockQuoteResponseProcessor());
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) JaxbDataFormat(org.apache.camel.model.dataformat.JaxbDataFormat)

Example 2 with JaxbDataFormat

use of org.apache.camel.model.dataformat.JaxbDataFormat in project wildfly-camel by wildfly-extras.

the class JAXBIntegrationTest method testJaxbUnmarshal.

@Test
public void testJaxbUnmarshal() throws Exception {
    final JaxbDataFormat format = new JaxbDataFormat();
    format.setContextPath("org.wildfly.camel.test.jaxb.model");
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").unmarshal(format);
        }
    });
    camelctx.start();
    try (InputStream input = getClass().getResourceAsStream("/customer.xml")) {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        Customer customer = producer.requestBody("direct:start", input, Customer.class);
        Assert.assertEquals("John", customer.getFirstName());
        Assert.assertEquals("Doe", customer.getLastName());
    } finally {
        camelctx.stop();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) RouteBuilder(org.apache.camel.builder.RouteBuilder) Customer(org.wildfly.camel.test.jaxb.model.Customer) InputStream(java.io.InputStream) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) JaxbDataFormat(org.apache.camel.model.dataformat.JaxbDataFormat) Test(org.junit.Test)

Example 3 with JaxbDataFormat

use of org.apache.camel.model.dataformat.JaxbDataFormat in project camel by apache.

the class ConsumerBreadcrumbIdTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            JaxbDataFormat jaxb = new JaxbDataFormat(false);
            jaxb.setContextPath("org.apache.camel.component.spring.ws.jaxb");
            // request webservice
            from("direct:webservice-marshall-asin").marshal(jaxb).to("spring-ws:http://localhost/?soapAction=http://www.stockquotes.edu/GetQuoteAsIn&webServiceTemplate=#webServiceTemplate").convertBodyTo(String.class);
            // provide web service
            from("spring-ws:soapaction:http://www.stockquotes.edu/GetQuoteAsIn?endpointMapping=#endpointMapping").setHeader("setin", constant("true")).process(new StockQuoteResponseProcessor());
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) JaxbDataFormat(org.apache.camel.model.dataformat.JaxbDataFormat)

Example 4 with JaxbDataFormat

use of org.apache.camel.model.dataformat.JaxbDataFormat in project camel by apache.

the class DataFormatClause method jaxb.

/**
     * Uses the JAXB data format with context path
     */
public T jaxb(String contextPath) {
    JaxbDataFormat dataFormat = new JaxbDataFormat();
    dataFormat.setContextPath(contextPath);
    return dataFormat(dataFormat);
}
Also used : SoapJaxbDataFormat(org.apache.camel.model.dataformat.SoapJaxbDataFormat) JaxbDataFormat(org.apache.camel.model.dataformat.JaxbDataFormat)

Example 5 with JaxbDataFormat

use of org.apache.camel.model.dataformat.JaxbDataFormat in project camel by apache.

the class JaxbMarshalNamespacePrefixMapperTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            JaxbDataFormat df = new JaxbDataFormat();
            df.setContextPath("org.apache.camel.example");
            df.setNamespacePrefixRef("myPrefix");
            from("direct:start").marshal(df).to("mock:result");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) JaxbDataFormat(org.apache.camel.model.dataformat.JaxbDataFormat)

Aggregations

JaxbDataFormat (org.apache.camel.model.dataformat.JaxbDataFormat)6 RouteBuilder (org.apache.camel.builder.RouteBuilder)5 InputStream (java.io.InputStream)2 CamelContext (org.apache.camel.CamelContext)2 ProducerTemplate (org.apache.camel.ProducerTemplate)2 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)2 Test (org.junit.Test)2 Customer (org.wildfly.camel.test.jaxb.model.Customer)2 SoapJaxbDataFormat (org.apache.camel.model.dataformat.SoapJaxbDataFormat)1