use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class SimpleMethodDispatcher method bind.
public void bind(OperationInfo o, Method... methods) {
Method primary = methods[0];
for (Method m : methods) {
methodToOp.put(m, o);
Map<BindingInfo, BindingOperationInfo> biToBop = new ConcurrentHashMap<>(4, 0.75f, 2);
infoMap.put(m, biToBop);
}
opToMethod.put(o, primary);
if (o.isUnwrappedCapable()) {
opToMethod.put(o.getUnwrappedOperation(), primary);
}
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class LoggingOutInterceptorTest method handleAndGetCachedOutputStream.
private CachedOutputStream handleAndGetCachedOutputStream(LoggingOutInterceptor interceptor) {
interceptor.setPrintWriter(new PrintWriter(new ByteArrayOutputStream()));
Endpoint endpoint = control.createMock(Endpoint.class);
EndpointInfo endpointInfo = control.createMock(EndpointInfo.class);
EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo).anyTimes();
BindingInfo bindingInfo = control.createMock(BindingInfo.class);
EasyMock.expect(endpointInfo.getBinding()).andReturn(bindingInfo).anyTimes();
EasyMock.expect(endpointInfo.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
EasyMock.expect(bindingInfo.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
control.replay();
Message message = new MessageImpl();
ExchangeImpl exchange = new ExchangeImpl();
message.setExchange(exchange);
exchange.put(Endpoint.class, endpoint);
message.put(Message.CONTENT_TYPE, "application/xml");
message.setContent(OutputStream.class, new ByteArrayOutputStream());
interceptor.handleMessage(message);
OutputStream os = message.getContent(OutputStream.class);
assertTrue(os instanceof CachedOutputStream);
return (CachedOutputStream) os;
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class SoapTransportFactory method getConduit.
public Conduit getConduit(EndpointInfo ei, EndpointReferenceType target, Bus bus) throws IOException {
String address = target == null ? ei.getAddress() : target.getAddress().getValue();
BindingInfo bi = ei.getBinding();
String transId = ei.getTransportId();
if (bi instanceof SoapBindingInfo) {
transId = ((SoapBindingInfo) bi).getTransportURI();
if (transId == null) {
transId = ei.getTransportId();
}
}
ConduitInitiator conduitInit;
try {
ConduitInitiatorManager mgr = bus.getExtension(ConduitInitiatorManager.class);
if (StringUtils.isEmpty(address) || address.startsWith("http") || address.startsWith("jms") || address.startsWith("soap.udp")) {
conduitInit = mgr.getConduitInitiator(mapTransportURI(transId, address));
} else {
conduitInit = mgr.getConduitInitiatorForUri(address);
}
if (conduitInit == null) {
throw new RuntimeException(String.format(CANNOT_GET_CONDUIT_ERROR, address, transId));
}
return conduitInit.getConduit(ei, target, bus);
} catch (BusException e) {
throw new RuntimeException(String.format(CANNOT_GET_CONDUIT_ERROR, address, transId));
}
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class RPCInInterceptor method getOperation.
private BindingOperationInfo getOperation(Message message, QName opName) {
BindingOperationInfo bop = ServiceModelUtil.getOperation(message.getExchange(), opName);
if (bop == null) {
Endpoint ep = message.getExchange().getEndpoint();
if (ep == null) {
return null;
}
BindingInfo service = ep.getEndpointInfo().getBinding();
boolean output = !isRequestor(message);
for (BindingOperationInfo info : service.getOperations()) {
if (info.getName().getLocalPart().equals(opName.getLocalPart())) {
final SoapBody body;
if (output) {
body = info.getOutput().getExtensor(SoapBody.class);
} else {
body = info.getInput().getExtensor(SoapBody.class);
}
if (body != null && opName.getNamespaceURI().equals(body.getNamespaceURI())) {
return info;
}
}
}
}
return bop;
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class AbstractWSDLBasedEndpointFactory method createEndpoint.
protected Endpoint createEndpoint() throws BusException, EndpointException {
serviceFactory.setFeatures(getFeatures());
if (serviceName != null) {
serviceFactory.setServiceName(serviceName);
}
if (endpointName != null) {
serviceFactory.setEndpointName(endpointName);
}
Service service = serviceFactory.getService();
if (service == null) {
initializeServiceFactory();
service = serviceFactory.create();
}
if (endpointName == null) {
endpointName = serviceFactory.getEndpointName();
}
EndpointInfo ei = service.getEndpointInfo(endpointName);
if (ei != null) {
if ((transportId != null && !ei.getTransportId().equals(transportId)) || (bindingId != null && !ei.getBinding().getBindingId().equals(bindingId))) {
ei = null;
} else {
BindingFactoryManager bfm = getBus().getExtension(BindingFactoryManager.class);
bindingFactory = bfm.getBindingFactory(ei.getBinding().getBindingId());
}
}
if (ei == null) {
if (getAddress() == null) {
ei = ServiceModelUtil.findBestEndpointInfo(serviceFactory.getInterfaceName(), service.getServiceInfos());
}
if (ei == null && !serviceFactory.isPopulateFromClass()) {
ei = ServiceModelUtil.findBestEndpointInfo(serviceFactory.getInterfaceName(), service.getServiceInfos());
if (ei != null) {
BindingFactoryManager bfm = getBus().getExtension(BindingFactoryManager.class);
bindingFactory = bfm.getBindingFactory(ei.getBinding().getBindingId());
}
if (ei == null) {
LOG.warning("Could not find endpoint/port for " + endpointName + " in wsdl. Creating default.");
} else if (!ei.getName().equals(endpointName)) {
LOG.warning("Could not find endpoint/port for " + endpointName + " in wsdl. Using " + ei.getName() + ".");
}
}
if (ei == null) {
ei = createEndpointInfo(null);
} else if (transportId != null && !ei.getTransportId().equals(transportId)) {
LOG.warning("Transport for endpoint/port " + endpointName + " in wsdl doesn't match " + transportId + ".");
BindingInfo bi = ei.getBinding();
ei = createEndpointInfo(bi);
} else if (bindingId != null && !ei.getBinding().getBindingId().equals(bindingId) && // consider SoapBinding has multiple default namespace
!(SoapBindingFactory.DEFAULT_NAMESPACES.contains(bindingId) && SoapBindingFactory.DEFAULT_NAMESPACES.contains(ei.getBinding().getBindingId()))) {
LOG.warning("Binding for endpoint/port " + endpointName + " in wsdl doesn't match " + bindingId + ".");
ei = createEndpointInfo(null);
} else if (getAddress() != null) {
ei.setAddress(getAddress());
if (ei.getAddress().startsWith("camel") || ei.getAddress().startsWith("local")) {
modifyTransportIdPerAddress(ei);
}
}
} else if (getAddress() != null) {
ei.setAddress(getAddress());
}
if (publishedEndpointUrl != null && !"".equals(publishedEndpointUrl)) {
ei.setProperty("publishedEndpointUrl", publishedEndpointUrl);
}
if (endpointReference != null) {
ei.setAddress(endpointReference);
}
Endpoint ep = service.getEndpoints().get(ei.getName());
if (ep == null) {
ep = serviceFactory.createEndpoint(ei);
((EndpointImpl) ep).initializeActiveFeatures(getFeatures());
} else {
serviceFactory.setEndpointName(ei.getName());
if (ep.getActiveFeatures() == null) {
((EndpointImpl) ep).initializeActiveFeatures(getFeatures());
}
}
if (properties != null) {
ep.putAll(properties);
}
service.getEndpoints().put(ep.getEndpointInfo().getName(), ep);
if (getInInterceptors() != null) {
ep.getInInterceptors().addAll(getInInterceptors());
ep.getInInterceptors().add(WSDLGetInterceptor.INSTANCE);
}
if (getOutInterceptors() != null) {
ep.getOutInterceptors().addAll(getOutInterceptors());
}
if (getInFaultInterceptors() != null) {
ep.getInFaultInterceptors().addAll(getInFaultInterceptors());
}
if (getOutFaultInterceptors() != null) {
ep.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
}
serviceFactory.sendEvent(FactoryBeanListener.Event.ENDPOINT_SELECTED, ei, ep, serviceFactory.getServiceClass(), getServiceClass());
return ep;
}
Aggregations