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);
}
}
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
}
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();
}
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"));
}
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"));
}
Aggregations