Search in sources :

Example 1 with Bus

use of org.apache.cxf.Bus in project Activiti by Activiti.

the class CxfWSDLImporter method importFrom.

public void importFrom(String url) {
    this.wsServices.clear();
    this.wsOperations.clear();
    this.structures.clear();
    this.wsdlLocation = url;
    try {
        Bus bus = BusFactory.getDefaultBus();
        final Enumeration<URL> xjcBindingUrls = Thread.currentThread().getContextClassLoader().getResources(JAXB_BINDINGS_RESOURCE);
        if (xjcBindingUrls.hasMoreElements()) {
            final URL xjcBindingUrl = xjcBindingUrls.nextElement();
            if (xjcBindingUrls.hasMoreElements()) {
                throw new ActivitiException("Several JAXB binding definitions found for activiti-cxf: " + JAXB_BINDINGS_RESOURCE);
            }
            DynamicClientFactory.newInstance(bus).createClient(url, Arrays.asList(new String[] { xjcBindingUrl.toString() }));
            WSDLManager wsdlManager = bus.getExtension(WSDLManager.class);
            Definition def = wsdlManager.getDefinition(url);
            WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
            List<ServiceInfo> services = builder.buildServices(def);
            for (ServiceInfo service : services) {
                WSService wsService = this.importService(service);
                this.wsServices.put(this.namespace + wsService.getName(), wsService);
            }
            if (def != null && def.getTypes() != null) {
                this.importTypes(def.getTypes());
            }
        } else {
            throw new ActivitiException("The JAXB binding definitions are not found for activiti-cxf: " + JAXB_BINDINGS_RESOURCE);
        }
    } catch (WSDLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        throw new ActivitiException("Error retrieveing the JAXB binding definitions", e);
    }
}
Also used : Bus(org.apache.cxf.Bus) ActivitiException(org.activiti.engine.ActivitiException) WSDLException(javax.wsdl.WSDLException) StructureDefinition(org.activiti.engine.impl.bpmn.data.StructureDefinition) SimpleStructureDefinition(org.activiti.engine.impl.bpmn.data.SimpleStructureDefinition) Definition(javax.wsdl.Definition) PrimitiveStructureDefinition(org.activiti.engine.impl.bpmn.data.PrimitiveStructureDefinition) IOException(java.io.IOException) URL(java.net.URL) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) WSDLManager(org.apache.cxf.wsdl.WSDLManager)

Example 2 with Bus

use of org.apache.cxf.Bus in project camel by apache.

the class Server method prepare.

public void prepare() throws Exception {
    // Set a system property used to configure the server.  The examples all run on port 9091; 
    // however, the unit tests must run on a dynamic port.  As such, we make the port configurable
    // in the Spring context.
    System.setProperty("port", "9001");
    // setup the Camel context for the Camel transport
    // START SNIPPET: e1
    SpringBusFactory bf = new SpringBusFactory();
    BusFactory.setDefaultBus(null);
    Bus bus = bf.createBus("/org/apache/camel/example/camel/transport/CamelDestination.xml");
    BusFactory.setDefaultBus(bus);
// END SNIPPET: e1
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory)

Example 3 with Bus

use of org.apache.cxf.Bus in project camel by apache.

the class CxfConsumerWSRMTest method testInvokeGreeter.

@Test
public void testInvokeGreeter() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    Bus clientBus = context.getRegistry().lookupByNameAndType("client-bus", Bus.class);
    assertNotNull(clientBus);
    BusFactory.setThreadDefaultBus(clientBus);
    try {
        Service service = Service.create(SERVICE_NAME);
        service.addPort(PORT_NAME, "http://schemas.xmlsoap.org/soap/", "http://localhost:" + CXFTestSupport.getPort1() + "/CxfConsumerWSRMTest/router");
        Greeter greeter = service.getPort(PORT_NAME, Greeter.class);
        greeter.greetMeOneWay("test");
    } finally {
        BusFactory.setThreadDefaultBus(null);
    }
    assertMockEndpointsSatisfied();
}
Also used : Bus(org.apache.cxf.Bus) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Greeter(org.apache.hello_world_soap_http.Greeter) Service(javax.xml.ws.Service) Test(org.junit.Test)

Example 4 with Bus

use of org.apache.cxf.Bus in project camel by apache.

the class WSSecurityRouteTest method testSignature.

@Test
public void testSignature() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = WSSecurityRouteTest.class.getResource("../client/wssec.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    GreeterService gs = new GreeterService();
    Greeter greeter = gs.getGreeterSignaturePort();
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + CXFTestSupport.getPort2() + "/WSSecurityRouteTest/GreeterSignaturePort");
    assertEquals("Get a wrong response", "Hello Security", greeter.greetMe("Security"));
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.camel.hello_world_soap_http.Greeter) GreeterService(org.apache.camel.hello_world_soap_http.GreeterService) URL(java.net.URL) Test(org.junit.Test)

Example 5 with Bus

use of org.apache.cxf.Bus in project camel by apache.

the class WSSecurityRouteTest method testEncryption.

@Test
public void testEncryption() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = WSSecurityRouteTest.class.getResource("../client/wssec.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    GreeterService gs = new GreeterService();
    Greeter greeter = gs.getGreeterEncryptionPort();
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + CXFTestSupport.getPort2() + "/WSSecurityRouteTest/GreeterEncryptionPort");
    assertEquals("Get a wrong response", "Hello Security", greeter.greetMe("Security"));
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.camel.hello_world_soap_http.Greeter) GreeterService(org.apache.camel.hello_world_soap_http.GreeterService) URL(java.net.URL) Test(org.junit.Test)

Aggregations

Bus (org.apache.cxf.Bus)1374 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)862 URL (java.net.URL)836 QName (javax.xml.namespace.QName)485 Service (javax.xml.ws.Service)446 DoubleItPortType (org.example.contract.doubleit.DoubleItPortType)347 Test (org.junit.Test)297 Client (org.apache.cxf.endpoint.Client)106 HashMap (java.util.HashMap)88 Message (org.apache.cxf.message.Message)69 Greeter (org.apache.hello_world.Greeter)66 SOAPService (org.apache.hello_world.services.SOAPService)65 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)60 ExtensionManagerBus (org.apache.cxf.bus.extension.ExtensionManagerBus)54 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)44 IOException (java.io.IOException)43 JAXRSClientFactoryBean (org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean)43 Endpoint (org.apache.cxf.endpoint.Endpoint)42 ArrayList (java.util.ArrayList)41 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)36