Search in sources :

Example 6 with SoapJaxbDataFormat

use of org.apache.camel.dataformat.soap.SoapJaxbDataFormat in project camel by apache.

the class Soap12MarshalTest method createDataFormat.

/**
     * Create data format by using the constructor
     */
protected SoapJaxbDataFormat createDataFormat() {
    String jaxbPackage = GetCustomersByName.class.getPackage().getName();
    ElementNameStrategy elStrat = new TypeNameStrategy();
    SoapJaxbDataFormat answer = new SoapJaxbDataFormat(jaxbPackage, elStrat);
    answer.setVersion("1.2");
    return answer;
}
Also used : ElementNameStrategy(org.apache.camel.dataformat.soap.name.ElementNameStrategy) GetCustomersByName(com.example.customerservice.GetCustomersByName) SoapJaxbDataFormat(org.apache.camel.dataformat.soap.SoapJaxbDataFormat) TypeNameStrategy(org.apache.camel.dataformat.soap.name.TypeNameStrategy)

Example 7 with SoapJaxbDataFormat

use of org.apache.camel.dataformat.soap.SoapJaxbDataFormat in project wildfly-camel by wildfly-extras.

the class SOAPServiceInterfaceStrategyIntegrationTest method testSOAPServiceInterfaceStrategyMarshal.

@Test
public void testSOAPServiceInterfaceStrategyMarshal() throws Exception {
    ServiceInterfaceStrategy strategy = new ServiceInterfaceStrategy(CustomerService.class, true);
    final SoapJaxbDataFormat format = new SoapJaxbDataFormat("org.wildfly.camel.test.common.types", strategy);
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").marshal(format);
        }
    });
    camelctx.start();
    try (InputStream input = getClass().getResourceAsStream("/envelope.xml")) {
        Customer customer = new Customer();
        customer.setFirstName("Kermit");
        customer.setLastName("The Frog");
        ProducerTemplate template = camelctx.createProducerTemplate();
        String result = template.requestBody("direct:start", customer, String.class);
        Assert.assertEquals(XMLUtils.compactXML(input), XMLUtils.compactXML(result));
    } finally {
        camelctx.stop();
    }
}
Also used : ServiceInterfaceStrategy(org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy) 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.common.types.Customer) InputStream(java.io.InputStream) SoapJaxbDataFormat(org.apache.camel.dataformat.soap.SoapJaxbDataFormat) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 8 with SoapJaxbDataFormat

use of org.apache.camel.dataformat.soap.SoapJaxbDataFormat in project wildfly-camel by wildfly-extras.

the class SOAPIntegrationTest method testSoapMarshal.

@Test
public void testSoapMarshal() throws Exception {
    final SoapJaxbDataFormat format = new SoapJaxbDataFormat();
    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").marshal(format);
        }
    });
    camelctx.start();
    try (InputStream input = getClass().getResourceAsStream("/envelope.xml")) {
        String expected = XMLUtils.compactXML(input);
        ProducerTemplate producer = camelctx.createProducerTemplate();
        Customer customer = new Customer("John", "Doe");
        String customerXML = producer.requestBody("direct:start", customer, String.class);
        Assert.assertEquals(expected, XMLUtils.compactXML(customerXML));
    } 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) SoapJaxbDataFormat(org.apache.camel.dataformat.soap.SoapJaxbDataFormat) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Aggregations

SoapJaxbDataFormat (org.apache.camel.dataformat.soap.SoapJaxbDataFormat)8 RouteBuilder (org.apache.camel.builder.RouteBuilder)6 InputStream (java.io.InputStream)5 CamelContext (org.apache.camel.CamelContext)5 ProducerTemplate (org.apache.camel.ProducerTemplate)5 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)5 Test (org.junit.Test)5 Element (org.w3c.dom.Element)2 Customer (org.wildfly.camel.test.jaxb.model.Customer)2 GetCustomersByName (com.example.customerservice.GetCustomersByName)1 HashMap (java.util.HashMap)1 CamelContextAware (org.apache.camel.CamelContextAware)1 RuntimeCamelException (org.apache.camel.RuntimeCamelException)1 ElementNameStrategy (org.apache.camel.dataformat.soap.name.ElementNameStrategy)1 ServiceInterfaceStrategy (org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy)1 TypeNameStrategy (org.apache.camel.dataformat.soap.name.TypeNameStrategy)1 DataFormatFactory (org.apache.camel.spi.DataFormatFactory)1 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)1 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1