Search in sources :

Example 81 with BindingInfo

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

the class ColocOutInterceptorTest method testColocOutIsColocatedPropertySet.

@Test
public void testColocOutIsColocatedPropertySet() throws Exception {
    colocOut = new TestColocOutInterceptor1();
    Bus bus = setupBus();
    ServerRegistry sr = control.createMock(ServerRegistry.class);
    EasyMock.expect(bus.getExtension(ServerRegistry.class)).andReturn(sr);
    // Funtion Param
    Server s1 = control.createMock(Server.class);
    List<Server> list = new ArrayList<>();
    list.add(s1);
    Endpoint sep = control.createMock(Endpoint.class);
    ex.put(Endpoint.class, sep);
    QName op = new QName("E", "F");
    QName intf = new QName("G", "H");
    BindingInfo sbi = control.createMock(BindingInfo.class);
    ServiceInfo ssi = new ServiceInfo();
    InterfaceInfo sii = new InterfaceInfo(ssi, intf);
    sii.addOperation(op);
    OperationInfo soi = sii.getOperation(op);
    ServiceInfo rsi = new ServiceInfo();
    InterfaceInfo rii = new InterfaceInfo(rsi, intf);
    rii.addOperation(op);
    OperationInfo roi = rii.getOperation(op);
    BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
    BindingOperationInfo rboi = control.createMock(BindingOperationInfo.class);
    ex.put(BindingOperationInfo.class, sboi);
    // Local var
    Service ses = control.createMock(Service.class);
    EndpointInfo sei = control.createMock(EndpointInfo.class);
    Endpoint rep = control.createMock(Endpoint.class);
    Service res = control.createMock(Service.class);
    BindingInfo rbi = control.createMock(BindingInfo.class);
    EndpointInfo rei = control.createMock(EndpointInfo.class);
    EasyMock.expect(sr.getServers()).andReturn(list);
    EasyMock.expect(sep.getService()).andReturn(ses);
    EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
    EasyMock.expect(s1.getEndpoint()).andReturn(rep);
    EasyMock.expect(rep.getService()).andReturn(res);
    EasyMock.expect(rep.getEndpointInfo()).andReturn(rei);
    EasyMock.expect(ses.getName()).andReturn(new QName("A", "B"));
    EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
    EasyMock.expect(rei.getName()).andReturn(new QName("C", "D"));
    EasyMock.expect(sei.getName()).andReturn(new QName("C", "D"));
    EasyMock.expect(rei.getBinding()).andReturn(rbi);
    EasyMock.expect(sboi.getName()).andReturn(op).anyTimes();
    EasyMock.expect(sboi.getOperationInfo()).andReturn(soi);
    EasyMock.expect(rboi.getName()).andReturn(op).anyTimes();
    EasyMock.expect(rboi.getOperationInfo()).andReturn(roi);
    EasyMock.expect(rbi.getOperation(op)).andReturn(rboi);
    InterceptorChain chain = control.createMock(InterceptorChain.class);
    msg.setInterceptorChain(chain);
    EasyMock.expect(sboi.getBinding()).andReturn(sbi);
    EasyMock.expect(sbi.getInterface()).andReturn(sii);
    control.replay();
    colocOut.handleMessage(msg);
    assertTrue("COLOCATED property should be set", (Boolean) msg.get(COLOCATED));
    assertEquals("Message.WSDL_OPERATION property should be set", op, msg.get(Message.WSDL_OPERATION));
    assertEquals("Message.WSDL_INTERFACE property should be set", intf, msg.get(Message.WSDL_INTERFACE));
    control.verify();
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) Bus(org.apache.cxf.Bus) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Server(org.apache.cxf.endpoint.Server) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ServerRegistry(org.apache.cxf.endpoint.ServerRegistry) Service(org.apache.cxf.service.Service) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) InterceptorChain(org.apache.cxf.interceptor.InterceptorChain) Endpoint(org.apache.cxf.endpoint.Endpoint) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Test(org.junit.Test)

Example 82 with BindingInfo

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

the class AbstractJAXRSFactoryBean method createEndpointInfo.

/*
     * EndpointInfo contains information form WSDL's physical part such as
     * endpoint address, binding, transport etc. For JAX-RS based EndpointInfo,
     * as there is no WSDL, these information are set manually, eg, default
     * transport is http, binding is JAX-RS binding, endpoint address is from
     * server mainline.
     */
protected EndpointInfo createEndpointInfo(Service service) throws BusException {
    String transportId = getTransportId();
    if (transportId == null && getAddress() != null) {
        DestinationFactory df = getDestinationFactory();
        if (df == null) {
            DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class);
            df = dfm.getDestinationFactoryForUri(getAddress());
            super.setDestinationFactory(df);
        }
        if (df != null) {
            transportId = df.getTransportIds().get(0);
        }
    }
    // default to http transport
    if (transportId == null) {
        transportId = "http://cxf.apache.org/transports/http";
    }
    setTransportId(transportId);
    // EndpointInfo ei = new EndpointInfo(service.getServiceInfos().get(0), transportId);
    EndpointInfo ei = new EndpointInfo();
    ei.setTransportId(transportId);
    ei.setName(serviceFactory.getService().getName());
    ei.setAddress(getAddress());
    BindingInfo bindingInfo = createBindingInfo();
    ei.setBinding(bindingInfo);
    if (!StringUtils.isEmpty(publishedEndpointUrl)) {
        ei.setProperty("publishedEndpointUrl", publishedEndpointUrl);
    }
    ei.setName(service.getName());
    serviceFactory.sendEvent(FactoryBeanListener.Event.ENDPOINTINFO_CREATED, ei);
    return ei;
}
Also used : DestinationFactory(org.apache.cxf.transport.DestinationFactory) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) BindingInfo(org.apache.cxf.service.model.BindingInfo)

Example 83 with BindingInfo

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

the class AbstractJAXRSFactoryBean method createBindingInfo.

protected BindingInfo createBindingInfo() {
    BindingFactoryManager mgr = getBus().getExtension(BindingFactoryManager.class);
    String binding = getBindingId();
    BindingConfiguration bindingConfig = getBindingConfig();
    if (binding == null && bindingConfig != null) {
        binding = bindingConfig.getBindingId();
    }
    if (binding == null) {
        binding = JAXRSBindingFactory.JAXRS_BINDING_ID;
    }
    try {
        BindingFactory bindingFactory = mgr.getBindingFactory(binding);
        setBindingFactory(bindingFactory);
        BindingInfo bi = bindingFactory.createBindingInfo(serviceFactory.getService(), binding, bindingConfig);
        for (BindingOperationInfo boi : bi.getOperations()) {
            serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_OPERATION_CREATED, bi, boi, null);
        }
        serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_CREATED, bi);
        return bi;
    } catch (BusException ex) {
        ex.printStackTrace();
    // do nothing
    }
    return null;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) BusException(org.apache.cxf.BusException) BindingConfiguration(org.apache.cxf.binding.BindingConfiguration) BindingFactory(org.apache.cxf.binding.BindingFactory)

Example 84 with BindingInfo

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

the class CodeFirstWSDLTest method createService.

private Definition createService(Class<?> clazz) throws Exception {
    JaxWsImplementorInfo info = new JaxWsImplementorInfo(clazz);
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean(info);
    Bus bus = getBus();
    bean.setBus(bus);
    Service service = bean.create();
    InterfaceInfo i = service.getServiceInfos().get(0).getInterface();
    assertEquals(5, i.getOperations().size());
    ServerFactoryBean svrFactory = new ServerFactoryBean();
    svrFactory.setBus(bus);
    svrFactory.setServiceFactory(bean);
    svrFactory.setServiceBean(clazz.newInstance());
    svrFactory.setAddress(address);
    svrFactory.create();
    Collection<BindingInfo> bindings = service.getServiceInfos().get(0).getBindings();
    assertEquals(1, bindings.size());
    ServiceWSDLBuilder wsdlBuilder = new ServiceWSDLBuilder(bus, service.getServiceInfos().get(0));
    return wsdlBuilder.build();
}
Also used : Bus(org.apache.cxf.Bus) JaxWsImplementorInfo(org.apache.cxf.jaxws.support.JaxWsImplementorInfo) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BindingInfo(org.apache.cxf.service.model.BindingInfo) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) ServiceWSDLBuilder(org.apache.cxf.wsdl11.ServiceWSDLBuilder)

Example 85 with BindingInfo

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

the class MAPAggregatorTest method setUpUsingAddressing.

private void setUpUsingAddressing(Message message, Exchange exchange, boolean usingAddressing) {
    setUpMessageExchange(message, exchange);
    Endpoint endpoint = control.createMock(Endpoint.class);
    endpoint.getOutInterceptors();
    EasyMock.expectLastCall().andReturn(new ArrayList<Interceptor<? extends Message>>()).anyTimes();
    setUpExchangeGet(exchange, Endpoint.class, endpoint);
    EndpointInfo endpointInfo = control.createMock(EndpointInfo.class);
    endpoint.getEndpointInfo();
    EasyMock.expectLastCall().andReturn(endpointInfo).anyTimes();
    List<ExtensibilityElement> endpointExts = new ArrayList<>();
    endpointInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
    EasyMock.expectLastCall().andReturn(endpointExts).anyTimes();
    BindingInfo bindingInfo = control.createMock(BindingInfo.class);
    endpointInfo.getBinding();
    EasyMock.expectLastCall().andReturn(bindingInfo).anyTimes();
    bindingInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
    EasyMock.expectLastCall().andReturn(Collections.EMPTY_LIST).anyTimes();
    ServiceInfo serviceInfo = control.createMock(ServiceInfo.class);
    endpointInfo.getService();
    EasyMock.expectLastCall().andReturn(serviceInfo).anyTimes();
    serviceInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
    EasyMock.expectLastCall().andReturn(Collections.EMPTY_LIST).anyTimes();
    ExtensibilityElement ext = control.createMock(ExtensibilityElement.class);
    if (usingAddressing) {
        QName elementType = usingAddressing ? Names.WSAW_USING_ADDRESSING_QNAME : new QName(SOAP_NAMESPACE, "encodingStyle");
        ext.getElementType();
        EasyMock.expectLastCall().andReturn(elementType).anyTimes();
        endpointExts.add(ext);
    }
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) QName(javax.xml.namespace.QName) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) ArrayList(java.util.ArrayList) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

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