Java 类org.apache.camel.dataformat.soap.SoapJaxbDataFormat 实例源码

项目:Camel    文件:SoapJaxbDataFormatAutoConfiguration.java   
@Bean
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(SoapJaxbDataFormat.class)
public SoapJaxbDataFormat configureSoapJaxbDataFormat(
        CamelContext camelContext,
        SoapJaxbDataFormatConfiguration configuration) throws Exception {
    SoapJaxbDataFormat dataformat = new SoapJaxbDataFormat();
    if (dataformat instanceof CamelContextAware) {
        ((CamelContextAware) dataformat).setCamelContext(camelContext);
    }
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    IntrospectionSupport.setProperties(camelContext,
            camelContext.getTypeConverter(), dataformat, parameters);
    return dataformat;
}
项目:wildfly-camel    文件:SOAPIntegrationTest.java   
@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();
    }
}
项目:wildfly-camel    文件:SOAPIntegrationTest.java   
@Test
public void testSoapUnmarshal() 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")
            .unmarshal(format);
        }
    });

    camelctx.start();
    try (InputStream input = getClass().getResourceAsStream("/envelope.xml")) {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        Element response = producer.requestBody("direct:start", input, Element.class);
        Assert.assertEquals("Customer", response.getLocalName());
    } finally {
        camelctx.stop();
    }
}
项目:wildfly-camel    文件:SOAPIntegrationTest.java   
@Test
public void testSoapV1_2Marshal() 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-1.2-marshal.xml")) {
        String expected = camelctx.getTypeConverter().mandatoryConvertTo(String.class, 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();
    }
}
项目:wildfly-camel    文件:SOAPIntegrationTest.java   
@Test
public void testSoapV1_2Unmarshal() throws Exception {

    final SoapJaxbDataFormat format = new SoapJaxbDataFormat();
    format.setContextPath("org.wildfly.camel.test.jaxb.model");
    format.setVersion("1.2");

    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("/envelope-1.2-unmarshal.xml")) {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        Element response = producer.requestBody("direct:start", input, Element.class);
        Assert.assertEquals("Customer", response.getLocalName());
    } finally {
        camelctx.stop();
    }
}
项目:Camel    文件:Soap12MarshalTest.java   
/**
 * 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;
}
项目:Camel    文件:Soap12MarshalTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            SoapJaxbDataFormat df = createDataFormat();
            from("direct:start") //
                .marshal(df) //
                .to("mock:result");
        }
    };
}
项目:t5-doc    文件:ApplicationConfiguration.java   
@Bean(name = "rivtaObservationsDataFormat")
public SoapJaxbDataFormat soapJaxbDataFormat() {
    return new SoapJaxbDataFormat("se.riv.clinicalprocess.healthcond.basic.getobservationsresponder.v1",
            new ServiceInterfaceStrategy(
                    se.riv.clinicalprocess.healthcond.basic.getobservations.v1.rivtabp21.GetObservationsResponderInterface.class,
                    false));
}
项目:wildfly-camel    文件:SOAPServiceInterfaceStrategyIntegrationTest.java   
@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();
    }
}