Search in sources :

Example 61 with BindingInfo

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);
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) Method(java.lang.reflect.Method) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 62 with BindingInfo

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;
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) Message(org.apache.cxf.message.Message) HashMap(java.util.HashMap) BindingInfo(org.apache.cxf.service.model.BindingInfo) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CachedOutputStream(org.apache.cxf.io.CachedOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) PrintWriter(java.io.PrintWriter) CachedOutputStream(org.apache.cxf.io.CachedOutputStream)

Example 63 with BindingInfo

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));
    }
}
Also used : BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) ConduitInitiator(org.apache.cxf.transport.ConduitInitiator) BusException(org.apache.cxf.BusException)

Example 64 with BindingInfo

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;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBody(org.apache.cxf.binding.soap.wsdl.extensions.SoapBody)

Example 65 with BindingInfo

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;
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) Service(org.apache.cxf.service.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager)

Aggregations

BindingInfo (org.apache.cxf.service.model.BindingInfo)103 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)65 QName (javax.xml.namespace.QName)45 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)44 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)35 Test (org.junit.Test)29 Endpoint (org.apache.cxf.endpoint.Endpoint)28 OperationInfo (org.apache.cxf.service.model.OperationInfo)21 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)20 Service (org.apache.cxf.service.Service)18 SoapBindingInfo (org.apache.cxf.binding.soap.model.SoapBindingInfo)17 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)17 Exchange (org.apache.cxf.message.Exchange)15 Message (org.apache.cxf.message.Message)13 ArrayList (java.util.ArrayList)11 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)11 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)11 MessageImpl (org.apache.cxf.message.MessageImpl)11 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)9 Bus (org.apache.cxf.Bus)8