org.apache.camel.component.cxf.CxfEndpoint Java Examples

The following examples show how to use org.apache.camel.component.cxf.CxfEndpoint. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Application.java    From wildfly-camel-examples with Apache License 2.0 6 votes vote down vote up
@Named("cxfProducerEndpoint")
@Produces
public CxfEndpoint createCxfProducerEndpoint() {
    CxfEndpoint cxfProducerEndpoint = this.camelContext.getEndpoint(CXF_ENDPOINT_URI, CxfEndpoint.class);
    cxfProducerEndpoint.setBeanId("cxfProducerEndpoint");
    cxfProducerEndpoint.setServiceClass(GreetingService.class);

    SSLContextParameters producerSslContextParameters = this.createProducerSSLContextParameters();
    cxfProducerEndpoint.setSslContextParameters(producerSslContextParameters);

    // Not for use in production
    HostnameVerifier hostnameVerifier = new HostnameVerifier() {
        @Override
        public boolean verify(String hostname, SSLSession session) {
            return true;
        }
    };
    cxfProducerEndpoint.setHostnameVerifier(hostnameVerifier);

    return cxfProducerEndpoint;
}
 
Example #2
Source File: Application.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Named("cxfProducerEndpointRel")
@Produces
public CxfEndpoint createCxfProducerEndpointRel() {
    CxfComponent cxfProducerComponent = new CxfComponent(this.camelContext);
    CxfEndpoint cxfProducerEndpoint = new CxfEndpoint(CXF_ENDPOINT_REL_URI, cxfProducerComponent);
    cxfProducerEndpoint.setBeanId("cxfProducerEndpointRel");
    cxfProducerEndpoint.setServiceClass(GreetingService.class);

    // Not for use in production
    HostnameVerifier hostnameVerifier = new HostnameVerifier() {
        @Override
        public boolean verify(String hostname, SSLSession session) {
            return true;
        }
    };
    cxfProducerEndpoint.setHostnameVerifier(hostnameVerifier);

    return cxfProducerEndpoint;
}
 
Example #3
Source File: Application.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Named("cxfProducerEndpointSub")
@Produces
public CxfEndpoint createCxfProducerEndpointSub() {
    CxfComponent cxfProducerComponent = new CxfComponent(this.camelContext);
    CxfEndpoint cxfProducerEndpoint = new CxfEndpoint(CXF_ENDPOINT_SUB_URI, cxfProducerComponent);
    cxfProducerEndpoint.setBeanId("cxfProducerEndpointSub");
    cxfProducerEndpoint.setServiceClass(GreetingService.class);

    // Not for use in production
    HostnameVerifier hostnameVerifier = new HostnameVerifier() {
        @Override
        public boolean verify(String hostname, SSLSession session) {
            return true;
        }
    };
    cxfProducerEndpoint.setHostnameVerifier(hostnameVerifier);

    return cxfProducerEndpoint;
}
 
Example #4
Source File: Application.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Named("cxfProducerEndpoint")
@Produces
public CxfEndpoint createCxfProducerEndpoint() {
    CxfComponent cxfProducerComponent = new CxfComponent(this.camelContext);
    CxfEndpoint cxfProducerEndpoint = new CxfEndpoint(CXF_ENDPOINT_URI, cxfProducerComponent);
    cxfProducerEndpoint.setBeanId("cxfProducerEndpoint");
    cxfProducerEndpoint.setServiceClass(GreetingService.class);

    // Not for use in production
    HostnameVerifier hostnameVerifier = new HostnameVerifier() {
        @Override
        public boolean verify(String hostname, SSLSession session) {
            return true;
        }
    };
    cxfProducerEndpoint.setHostnameVerifier(hostnameVerifier);

    return cxfProducerEndpoint;
}
 
Example #5
Source File: ApplicationB.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Named("cxfProducerEndpointB")
@Produces
public CxfEndpoint createCxfProducerEndpoint() {
    CxfComponent cxfProducerComponent = new CxfComponent(this.camelContext);
    CxfEndpoint cxfProducerEndpoint = new CxfEndpoint(CXF_ENDPOINT_URI, cxfProducerComponent);
    cxfProducerEndpoint.setBeanId("cxfProducerEndpointB");
    cxfProducerEndpoint.setServiceClass(GreetingService.class);

    // Not for use in production
    HostnameVerifier hostnameVerifier = new HostnameVerifier() {
        @Override
        public boolean verify(String hostname, SSLSession session) {
            return true;
        }
    };
    cxfProducerEndpoint.setHostnameVerifier(hostnameVerifier);

    return cxfProducerEndpoint;
}
 
Example #6
Source File: Application.java    From wildfly-camel-examples with Apache License 2.0 5 votes vote down vote up
@Named("cxfConsumerEndpoint")
@Produces
public CxfEndpoint createCxfConsumerEndpoint() {
    CxfEndpoint cxfConsumerEndpoint = this.camelContext.getEndpoint(CXF_ENDPOINT_URI, CxfEndpoint.class);
    cxfConsumerEndpoint.setBeanId("cxfConsumerEndpoint");
    cxfConsumerEndpoint.setServiceClass(GreetingService.class);

    return cxfConsumerEndpoint;
}
 
Example #7
Source File: CXFWSInterceptorTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Test
public void testCXFInterceptor() throws Exception {
    CountDownLatch latch = new CountDownLatch(1);

    CamelContext camelctx = new DefaultCamelContext();

    CxfComponent component = new CxfComponent(camelctx);
    CxfEndpoint cxfEndpoint = new CxfEndpoint("http://localhost:8080/EndpointService/EndpointPort", component);
    cxfEndpoint.setServiceClass(Endpoint.class);

    List<Interceptor<? extends Message>> inInterceptors = cxfEndpoint.getInInterceptors();
    inInterceptors.add(new CountDownInterceptor(latch));

    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from(cxfEndpoint)
            .setBody(constant("Hello ${body}"));
        }
    });

    camelctx.start();
    try {
        QName qname = new QName("http://wildfly.camel.test.cxf", "EndpointService");
        Service service = Service.create(new URL("http://localhost:8080/EndpointService/EndpointPort?wsdl"), qname);
        Endpoint endpoint = service.getPort(Endpoint.class);
        endpoint.echo("Kermit");
        Assert.assertTrue("Gave up waiting for CXF interceptor handleMessage", latch.await(5, TimeUnit.SECONDS));
    } finally {
        camelctx.close();
    }
}
 
Example #8
Source File: Application.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Named("cxfConsumerEndpointRel")
@Produces
public CxfEndpoint createCxfConsumerEndpointRel() {
    CxfComponent cxfConsumerComponent = new CxfComponent(this.camelContext);
    CxfEndpoint cxfConsumerEndpoint = new CxfEndpoint(CXF_ENDPOINT_REL_URI, cxfConsumerComponent);
    cxfConsumerEndpoint.setBeanId("cxfConsumerEndpointRel");
    cxfConsumerEndpoint.setServiceClass(GreetingService.class);
    return cxfConsumerEndpoint;
}
 
Example #9
Source File: Application.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Named("cxfConsumerEndpointSub")
@Produces
public CxfEndpoint createCxfConsumerEndpointSub() {
    CxfComponent cxfConsumerComponent = new CxfComponent(this.camelContext);
    CxfEndpoint cxfConsumerEndpoint = new CxfEndpoint(CXF_ENDPOINT_SUB_URI, cxfConsumerComponent);
    cxfConsumerEndpoint.setBeanId("cxfConsumerEndpointSub");
    cxfConsumerEndpoint.setServiceClass(GreetingService.class);
    return cxfConsumerEndpoint;
}
 
Example #10
Source File: Application.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Named("cxfConsumerEndpoint")
@Produces
public CxfEndpoint createCxfConsumerEndpoint() {
    CxfComponent cxfConsumerComponent = new CxfComponent(this.camelContext);
    CxfEndpoint cxfConsumerEndpoint = new CxfEndpoint(CXF_ENDPOINT_URI, cxfConsumerComponent);
    cxfConsumerEndpoint.setBeanId("cxfConsumerEndpoint");
    cxfConsumerEndpoint.setServiceClass(GreetingService.class);
    return cxfConsumerEndpoint;
}
 
Example #11
Source File: ApplicationB.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Named("cxfConsumerEndpointB")
@Produces
public CxfEndpoint createCxfConsumerEndpoint() {
    CxfComponent cxfConsumerComponent = new CxfComponent(this.camelContext);
    CxfEndpoint cxfConsumerEndpoint = new CxfEndpoint(CXF_ENDPOINT_URI, cxfConsumerComponent);
    cxfConsumerEndpoint.setBeanId("cxfConsumerEndpointB");
    cxfConsumerEndpoint.setServiceClass(GreetingService.class);
    return cxfConsumerEndpoint;
}
 
Example #12
Source File: CXFWSJAASAuthenticationIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
private CamelContext configureCamelContext(String password) throws Exception {
    CamelContext camelctx = new DefaultCamelContext();

    CxfComponent component = new CxfComponent(camelctx);
    CxfEndpoint consumerEndpoint = new CxfEndpoint("http://localhost:8080/webservices/greeting", component);
    consumerEndpoint.setServiceClass(Endpoint.class);

    List<Interceptor<? extends Message>> inInterceptors = consumerEndpoint.getInInterceptors();
    JAASLoginInterceptor interceptor =  new JAASLoginInterceptor();
    interceptor.setContextName("other");
    inInterceptors.add(interceptor);

    CxfEndpoint producerEndpoint = new CxfEndpoint("http://localhost:8080/webservices/greeting", component);
    producerEndpoint.setServiceClass(Endpoint.class);
    producerEndpoint.setUsername("user1");
    producerEndpoint.setPassword(password);

    Map<String, Object> properties = producerEndpoint.getProperties();
    if (properties == null) {
        producerEndpoint.setProperties(new HashMap<>());
    }

    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .to(producerEndpoint);

            from(consumerEndpoint)
            .process(exchange -> {
                Object[] args = exchange.getIn().getBody(Object[].class);
                exchange.getOut().setBody("Hello " + args[0]);
            });
        }
    });
    return camelctx;
}
 
Example #13
Source File: WildFlyCxfComponent.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
WildflyCxfConsumer(CxfEndpoint endpoint, Processor processor) throws Exception {
    super(endpoint, processor);
    URI uri = new URI(endpoint.getEndpointUri());
    String host = uri.getHost();
    int port = uri.getPort();
    if (!"localhost".equals(host) || port > 0) {
        LOGGER.warn("Ignoring configured host/port: {}", uri);
    }
}
 
Example #14
Source File: Application.java    From wildfly-camel-examples with Apache License 2.0 5 votes vote down vote up
@Named("cxfProducer")
@Produces
public CxfEndpoint createCxfProducer() {
    CxfEndpoint cxfToEndpoint = context.getEndpoint(CXF_ENDPOINT_URI, CxfEndpoint.class);
    cxfToEndpoint.setServiceClass(GreetingService.class);
    return cxfToEndpoint;
}
 
Example #15
Source File: Application.java    From wildfly-camel-examples with Apache License 2.0 5 votes vote down vote up
@Named("cxfConsumer")
@Produces
public CxfEndpoint createCxfConsumer() {
    CxfEndpoint cxfFromEndpoint = context.getEndpoint(CXF_ENDPOINT_URI, CxfEndpoint.class);
    cxfFromEndpoint.setServiceClass(GreetingService.class);
    return cxfFromEndpoint;
}
 
Example #16
Source File: CXFWSSecureConsumerIntegrationTest.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
private CxfEndpoint createCxfEndpoint(String endpointUrl, CxfComponent component) throws Exception {
    CxfEndpoint cxfEndpoint = new CxfEndpoint(endpointUrl, component);
    cxfEndpoint.setServiceClass(Endpoint.class.getName());
    return cxfEndpoint;
}
 
Example #17
Source File: CXFWSSecureConsumerIntegrationTest.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
@Test
public void testCXFSecureConsumer() throws Exception {
    CamelContext camelContext = new DefaultCamelContext();

    CxfComponent cxfComponent = camelContext.getComponent("cxf", CxfComponent.class);

    CxfEndpoint cxfProducer = createCxfEndpoint(SECURE_WS_ENDPOINT_URL, cxfComponent);
    cxfProducer.setSslContextParameters(createSSLContextParameters());

    CxfEndpoint cxfConsumer = createCxfEndpoint(SECURE_WS_ENDPOINT_URL, cxfComponent);

    camelContext.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .to(cxfProducer);

            from(cxfConsumer)
            .transform(simple("Hello ${body}"));
        }
    });

    try {
        // Force WildFly to generate a self-signed SSL cert & keystore
        HttpRequest.get("https://localhost:8443").throwExceptionOnFailure(false).getResponse();

        camelContext.start();

        ProducerTemplate template = camelContext.createProducerTemplate();
        String result = template.requestBody("direct:start", "Kermit", String.class);

        Assert.assertEquals("Hello Kermit", result);

        // Verify that if we attempt to use HTTP, we get a 302 redirect to the HTTPS endpoint URL
        HttpResponse response = HttpRequest.get(INSECURE_WS_ENDPOINT_URL + "?wsdl")
            .throwExceptionOnFailure(false)
            .followRedirects(false)
            .getResponse();
        Assert.assertEquals(302, response.getStatusCode());
        Assert.assertEquals(response.getHeader("Location"), SECURE_WS_ENDPOINT_URL + "?wsdl");
    } finally {
        camelContext.stop();
    }
}
 
Example #18
Source File: WildFlyCxfComponent.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
@Override
protected CxfEndpoint createCxfSpringEndpoint(String beanId) throws Exception {
    return super.createCxfSpringEndpoint(beanId);
}
 
Example #19
Source File: WildFlyCxfComponent.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
@Override
protected CxfEndpoint createCxfEndpoint(String remaining) {
    return new WildflyCxfEndpoint(remaining, this);
}
 
Example #20
Source File: SoapCxfProxyComponent.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Override
protected void configureDelegateEndpoint(ComponentDefinition definition, Endpoint endpoint, Map<String, Object> options) {
    super.configureDelegateEndpoint(definition, endpoint, options);
    ((CxfEndpoint)((ComponentProxyEndpoint)endpoint).getEndpoint()).setCxfConfigurer(endpointConfigurer);
}