Search in sources :

Example 21 with BindingInfo

use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.

the class EndpointSelectionInterceptor method selectEndpoint.

protected Endpoint selectEndpoint(Message message, Set<Endpoint> eps) {
    SoapVersion sv = ((SoapMessage) message).getVersion();
    for (Endpoint e : eps) {
        EndpointInfo ei = e.getEndpointInfo();
        BindingInfo binding = ei.getBinding();
        if (binding instanceof SoapBindingInfo && ((SoapBindingInfo) binding).getSoapVersion().equals(sv)) {
            return e;
        }
    }
    return null;
}
Also used : SoapVersion(org.apache.cxf.binding.soap.SoapVersion) 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) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapMessage(org.apache.cxf.binding.soap.SoapMessage)

Example 22 with BindingInfo

use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.

the class RequestPreprocessorTest method mockMessage.

private Message mockMessage(String baseAddress, String pathInfo, String query, String method, String methodHeader) {
    Message m = new MessageImpl();
    m.put("org.apache.cxf.http.case_insensitive_queries", false);
    m.put("org.apache.cxf.endpoint.private", false);
    Exchange e = new ExchangeImpl();
    m.setExchange(e);
    control.reset();
    Endpoint endp = control.mock(Endpoint.class);
    e.put(Endpoint.class, endp);
    EasyMock.expect(endp.isEmpty()).andReturn(true).anyTimes();
    EasyMock.expect(endp.get(ServerProviderFactory.class.getName())).andReturn(ServerProviderFactory.getInstance()).anyTimes();
    ServletDestination d = control.createMock(ServletDestination.class);
    e.setDestination(d);
    EndpointInfo epr = new EndpointInfo();
    epr.setAddress(baseAddress);
    EasyMock.expect(d.getEndpointInfo()).andReturn(epr).anyTimes();
    EasyMock.expect(endp.getEndpointInfo()).andReturn(epr).anyTimes();
    m.put(Message.REQUEST_URI, pathInfo);
    m.put(Message.QUERY_STRING, query);
    m.put(Message.HTTP_REQUEST_METHOD, method);
    Map<String, List<String>> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    if (methodHeader != null) {
        headers.put("X-HTTP-Method-Override", Collections.singletonList(methodHeader));
    }
    m.put(Message.PROTOCOL_HEADERS, headers);
    BindingInfo bi = control.createMock(BindingInfo.class);
    epr.setBinding(bi);
    EasyMock.expect(bi.getProperties()).andReturn(Collections.emptyMap()).anyTimes();
    control.replay();
    return m;
}
Also used : Exchange(org.apache.cxf.message.Exchange) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) ServletDestination(org.apache.cxf.transport.servlet.ServletDestination) Message(org.apache.cxf.message.Message) Endpoint(org.apache.cxf.endpoint.Endpoint) BindingInfo(org.apache.cxf.service.model.BindingInfo) List(java.util.List) TreeMap(java.util.TreeMap) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 23 with BindingInfo

use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.

the class DispatchImpl method addInvokeOperation.

private void addInvokeOperation(QName operationName, boolean oneWay) {
    ServiceInfo info = client.getEndpoint().getEndpointInfo().getService();
    OperationInfo invokeOpInfo = info.getInterface().getOperation(oneWay ? INVOKE_ONEWAY_QNAME : INVOKE_QNAME);
    OperationInfo opInfo = info.getInterface().addOperation(operationName);
    opInfo.setInput(invokeOpInfo.getInputName(), invokeOpInfo.getInput());
    if (!oneWay) {
        opInfo.setOutput(invokeOpInfo.getOutputName(), invokeOpInfo.getOutput());
    }
    for (BindingInfo bind : client.getEndpoint().getEndpointInfo().getService().getBindings()) {
        BindingOperationInfo bo = new BindingOperationInfo(bind, opInfo);
        bind.addOperation(bo);
    }
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo)

Example 24 with BindingInfo

use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.

the class ServiceImpl method createEndpointInfo.

private EndpointInfo createEndpointInfo(AbstractServiceFactoryBean serviceFactory, QName portName, PortInfoImpl portInfo) throws BusException {
    String address = portInfo.getAddress();
    String bindingID = BindingID.getBindingID(portInfo.getBindingID());
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    try {
        // the bindingId might be the transportId, just attempt to
        // load it to force the factory to load
        dfm.getDestinationFactory(bindingID);
    } catch (BusException ex) {
    // ignore
    }
    DestinationFactory df = dfm.getDestinationFactoryForUri(address);
    final String transportId;
    if (df != null && df.getTransportIds() != null && !df.getTransportIds().isEmpty()) {
        transportId = df.getTransportIds().get(0);
    } else {
        transportId = bindingID;
    }
    Object config = null;
    if (serviceFactory instanceof JaxWsServiceFactoryBean) {
        config = new JaxWsSoapBindingConfiguration((JaxWsServiceFactoryBean) serviceFactory);
    }
    BindingInfo bindingInfo = bus.getExtension(BindingFactoryManager.class).getBindingFactory(bindingID).createBindingInfo(serviceFactory.getService(), bindingID, config);
    Service service = serviceFactory.getService();
    service.getServiceInfos().get(0).addBinding(bindingInfo);
    EndpointInfo ei = new EndpointInfo(service.getServiceInfos().get(0), transportId);
    ei.setName(portName);
    ei.setAddress(address);
    ei.setBinding(bindingInfo);
    service.getServiceInfos().get(0).addEndpoint(ei);
    return ei;
}
Also used : DestinationFactory(org.apache.cxf.transport.DestinationFactory) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) BindingInfo(org.apache.cxf.service.model.BindingInfo) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) JaxWsSoapBindingConfiguration(org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration) BusException(org.apache.cxf.BusException)

Example 25 with BindingInfo

use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.

the class ServiceImpl method createDispatchService.

private AbstractServiceFactoryBean createDispatchService(DataBinding db) {
    AbstractServiceFactoryBean serviceFactory;
    final Service dispatchService;
    if (null != wsdlURL) {
        WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
        dispatchService = sf.create();
        dispatchService.setDataBinding(db);
        serviceFactory = sf;
    } else {
        ReflectionServiceFactoryBean sf = new JaxWsServiceFactoryBean();
        sf.setBus(bus);
        sf.setServiceName(serviceName);
        // maybe we can find another way to create service which have no SEI
        sf.setServiceClass(DummyImpl.class);
        sf.setDataBinding(db);
        dispatchService = sf.create();
        serviceFactory = sf;
    }
    configureObject(dispatchService);
    for (ServiceInfo si : dispatchService.getServiceInfos()) {
        si.setProperty("soap.force.doclit.bare", Boolean.TRUE);
        if (null == wsdlURL) {
            for (EndpointInfo ei : si.getEndpoints()) {
                ei.setProperty("soap.no.validate.parts", Boolean.TRUE);
            }
        }
        for (BindingInfo bind : si.getBindings()) {
            for (BindingOperationInfo bop : bind.getOperations()) {
                // force to bare, no unwrapping
                if (bop.isUnwrappedCapable()) {
                    bop.getOperationInfo().setUnwrappedOperation(null);
                    bop.setUnwrappedOperation(null);
                }
            }
        }
    }
    return serviceFactory;
}
Also used : AbstractServiceFactoryBean(org.apache.cxf.service.factory.AbstractServiceFactoryBean) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) WSDLServiceFactory(org.apache.cxf.wsdl11.WSDLServiceFactory) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BindingInfo(org.apache.cxf.service.model.BindingInfo) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)

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