use of org.apache.cxf.transport.DestinationFactoryManager in project cxf by apache.
the class JaxWsServiceConfigurationTest method getMockedServiceModel.
private ServiceInfo getMockedServiceModel(String wsdlUrl) throws Exception {
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose", false);
Definition def = wsdlReader.readWSDL(new CatalogWSDLLocator(wsdlUrl));
IMocksControl control = EasyMock.createNiceControl();
Bus bus = control.createMock(Bus.class);
BindingFactoryManager bindingFactoryManager = control.createMock(BindingFactoryManager.class);
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
Service service = null;
for (Iterator<?> it = def.getServices().values().iterator(); it.hasNext(); ) {
Object obj = it.next();
if (obj instanceof Service) {
service = (Service) obj;
break;
}
}
EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
control.replay();
ServiceInfo serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
serviceInfo.setProperty(WSDLServiceBuilder.WSDL_DEFINITION, null);
serviceInfo.setProperty(WSDLServiceBuilder.WSDL_SERVICE, null);
return serviceInfo;
}
use of org.apache.cxf.transport.DestinationFactoryManager in project cxf by apache.
the class CXFNonSpringServlet method getDestinationRegistryFromBusOrDefault.
protected DestinationRegistry getDestinationRegistryFromBusOrDefault(final String transportId) {
DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
try {
String peferredTransportId = transportId;
// extension or customization).
if (StringUtils.isEmpty(peferredTransportId) && getBus() != null) {
peferredTransportId = (String) getBus().getProperty(AbstractTransportFactory.PREFERRED_TRANSPORT_ID);
}
if (StringUtils.isEmpty(peferredTransportId)) {
final Set<String> candidates = dfm.getRegisteredDestinationFactoryNames();
// consider other candidates
if (!candidates.contains(DEFAULT_TRANSPORT_ID)) {
peferredTransportId = candidates.stream().filter(name -> name.endsWith("/configuration")).findAny().orElse(DEFAULT_TRANSPORT_ID);
}
}
DestinationFactory df = StringUtils.isEmpty(peferredTransportId) ? dfm.getDestinationFactory(DEFAULT_TRANSPORT_ID) : dfm.getDestinationFactory(peferredTransportId);
if (df instanceof HTTPTransportFactory) {
HTTPTransportFactory transportFactory = (HTTPTransportFactory) df;
return transportFactory.getRegistry();
}
} catch (BusException e) {
// why are we throwing a busexception if the DF isn't found?
}
return null;
}
use of org.apache.cxf.transport.DestinationFactoryManager in project cxf by apache.
the class MAPAggregatorTest method testGetReplyToUsingBaseAddress.
@Test
public void testGetReplyToUsingBaseAddress() throws Exception {
Message message = new MessageImpl();
Exchange exchange = new ExchangeImpl();
message.setExchange(exchange);
final String localReplyTo = "/SoapContext/decoupled";
final String decoupledEndpointBase = "http://localhost:8181/cxf";
final String replyTo = decoupledEndpointBase + localReplyTo;
ServiceInfo s = new ServiceInfo();
Service svc = new ServiceImpl(s);
EndpointInfo ei = new EndpointInfo();
InterfaceInfo ii = s.createInterface(new QName("FooInterface"));
s.setInterface(ii);
ii.addOperation(new QName("fooOp"));
SoapBindingInfo b = new SoapBindingInfo(s, "http://schemas.xmlsoap.org/soap/", Soap11.getInstance());
b.setTransportURI("http://schemas.xmlsoap.org/soap/http");
ei.setBinding(b);
ei.setAddress("http://nowhere.com/bar/foo");
ei.setName(new QName("http://nowhere.com/port", "foo"));
Bus bus = new ExtensionManagerBus();
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
DestinationFactory df = control.createMock(DestinationFactory.class);
Destination d = control.createMock(Destination.class);
bus.setExtension(dfm, DestinationFactoryManager.class);
EasyMock.expect(dfm.getDestinationFactoryForUri(localReplyTo)).andReturn(df);
EasyMock.expect(df.getDestination(EasyMock.anyObject(EndpointInfo.class), EasyMock.anyObject(Bus.class))).andReturn(d);
EasyMock.expect(d.getAddress()).andReturn(EndpointReferenceUtils.getEndpointReference(localReplyTo));
Endpoint ep = new EndpointImpl(bus, svc, ei);
exchange.put(Endpoint.class, ep);
exchange.put(Bus.class, bus);
exchange.setOutMessage(message);
setUpMessageProperty(message, REQUESTOR_ROLE, Boolean.TRUE);
message.getContextualProperty(WSAContextUtils.REPLYTO_PROPERTY);
message.put(WSAContextUtils.REPLYTO_PROPERTY, localReplyTo);
message.put(WSAContextUtils.DECOUPLED_ENDPOINT_BASE_PROPERTY, decoupledEndpointBase);
AddressingProperties maps = new AddressingProperties();
AttributedURIType id = ContextUtils.getAttributedURI("urn:uuid:12345");
maps.setMessageID(id);
maps.setAction(ContextUtils.getAttributedURI(""));
setUpMessageProperty(message, CLIENT_ADDRESSING_PROPERTIES, maps);
control.replay();
aggregator.mediate(message, false);
AddressingProperties props = (AddressingProperties) message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND);
assertEquals(replyTo, props.getReplyTo().getAddress().getValue());
control.verify();
}
use of org.apache.cxf.transport.DestinationFactoryManager in project tesb-rt-se by Talend.
the class RequestCallbackJmsTest method initialize.
@Before
public void initialize() throws Exception {
if (mep == NO_RUN) {
return;
}
final Bus bus = BusFactory.getDefaultBus();
final JMSTransportFactory jmsTransport = new JMSTransportFactory();
final DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", jmsTransport);
dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/jms", jmsTransport);
dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", jmsTransport);
dfm.registerDestinationFactory("http://cxf.apache.org/bindings/xformat", jmsTransport);
final ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/http", jmsTransport);
extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", jmsTransport);
extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/jms", jmsTransport);
extension.registerConduitInitiator("http://cxf.apache.org/bindings/xformat", jmsTransport);
final WSDLServiceFactory wsdlSvcFactory = new WSDLServiceFactory(CXFBusFactory.getThreadDefaultBus(), wsdlLocation);
final org.apache.cxf.service.Service cxfService = wsdlSvcFactory.create();
final ServiceInfo si = findServiceByName(cxfService, serviceName);
if (si == null) {
throw new RuntimeException("WSDL does not contain service " + serviceName);
}
final EndpointInfo ei = findEndpoint(si, portName);
if (ei == null) {
throw new RuntimeException("WSDL does not contain port " + portName);
}
endpointInfo = ei;
callbackMap.put("seekBookInBasementResponse", new SeekBookInBasementResponseCallback(messageTransfer));
callbackMap.put("seekBookInBasementFault", new SeekBookInBasementFaultCallback(messageTransfer));
}
use of org.apache.cxf.transport.DestinationFactoryManager in project tesb-rt-se by Talend.
the class RequestCallbackTest method initialize.
@Before
public void initialize() throws Exception {
if (mep == NO_RUN) {
return;
}
final Bus bus = BusFactory.getDefaultBus();
final LocalTransportFactory localTransport = new LocalTransportFactory();
final DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/jms", localTransport);
dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
dfm.registerDestinationFactory("http://cxf.apache.org/bindings/xformat", localTransport);
dfm.registerDestinationFactory("http://cxf.apache.org/transports/local", localTransport);
final ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
extension.registerConduitInitiator("http://cxf.apache.org/transports/local", localTransport);
extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);
extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/jms", localTransport);
extension.registerConduitInitiator("http://cxf.apache.org/bindings/xformat", localTransport);
final WSDLServiceFactory wsdlSvcFactory = new WSDLServiceFactory(CXFBusFactory.getThreadDefaultBus(), wsdlLocation, SERVICE_NAME);
final org.apache.cxf.service.Service cxfService = wsdlSvcFactory.create();
final ServiceInfo si = findServiceByName(cxfService, SERVICE_NAME);
if (si == null) {
throw new RuntimeException("WSDL does not contain service " + SERVICE_NAME);
}
final EndpointInfo ei = findEndpoint(si, PORT_NAME);
if (ei == null) {
throw new RuntimeException("WSDL does not contain port " + PORT_NAME);
}
endpointInfo = ei;
callbackMap.put("seekBookInBasementResponse", new SeekBookInBasementResponseCallback(messageTransfer));
callbackMap.put("seekBookInBasementFault", new SeekBookInBasementFaultCallback(messageTransfer));
}
Aggregations