Search in sources :

Example 31 with BindingFactoryManager

use of org.apache.cxf.binding.BindingFactoryManager in project cxf by apache.

the class WSDLServiceUtils method getBindingFactory.

public static BindingFactory getBindingFactory(Binding binding, Bus bus, StringBuilder sb) {
    BindingFactory factory = null;
    for (Object obj : binding.getExtensibilityElements()) {
        if (obj instanceof ExtensibilityElement) {
            ExtensibilityElement ext = (ExtensibilityElement) obj;
            sb.delete(0, sb.length());
            sb.append(ext.getElementType().getNamespaceURI());
            try {
                BindingFactoryManager manager = bus.getExtension(BindingFactoryManager.class);
                if (manager != null) {
                    factory = manager.getBindingFactory(sb.toString());
                }
            } catch (BusException e) {
            // ignore, we'll use a generic BindingInfo
            }
            if (factory != null) {
                break;
            }
        }
    }
    return factory;
}
Also used : BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) BusException(org.apache.cxf.BusException) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) BindingFactory(org.apache.cxf.binding.BindingFactory)

Example 32 with BindingFactoryManager

use of org.apache.cxf.binding.BindingFactoryManager in project cxf by apache.

the class ServiceWSDLBuilderTest method setupWSDL.

private void setupWSDL(String wsdlPath, boolean doXsdImports) throws Exception {
    String wsdlUrl = getClass().getResource(wsdlPath).toString();
    LOG.info("the path of wsdl file is " + wsdlUrl);
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    def = wsdlReader.readWSDL(wsdlUrl);
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    destinationFactoryManager = control.createMock(DestinationFactoryManager.class);
    destinationFactory = control.createMock(DestinationFactory.class);
    wsdlServiceBuilder = new WSDLServiceBuilder(bus, false);
    for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
        if (serv != null) {
            service = serv;
            break;
        }
    }
    EasyMock.expect(bus.getExtension(WSDLManager.class)).andReturn(new WSDLManagerImpl()).anyTimes();
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andReturn(destinationFactoryManager);
    EasyMock.expect(destinationFactoryManager.getDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/")).andReturn(destinationFactory);
    control.replay();
    serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
    ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, serviceInfo);
    builder.setUseSchemaImports(doXsdImports);
    builder.setBaseFileName("HelloWorld");
    newDef = builder.build(new HashMap<String, SchemaInfo>());
}
Also used : Bus(org.apache.cxf.Bus) DestinationFactory(org.apache.cxf.transport.DestinationFactory) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) HashMap(java.util.HashMap) Service(javax.wsdl.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLManager(org.apache.cxf.wsdl.WSDLManager) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 33 with BindingFactoryManager

use of org.apache.cxf.binding.BindingFactoryManager in project cxf by apache.

the class WSDLServiceBuilderTest method buildService.

private void buildService(QName endpointName) throws Exception {
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    destinationFactoryManager = control.createMock(DestinationFactoryManager.class);
    DestinationFactory destinationFactory = control.createMock(DestinationFactory.class);
    WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager).anyTimes();
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andReturn(destinationFactoryManager).atLeastOnce();
    EasyMock.expect(destinationFactoryManager.getDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/")).andReturn(destinationFactory).anyTimes();
    control.replay();
    serviceInfos = wsdlServiceBuilder.buildServices(def, service, endpointName);
    if (!serviceInfos.isEmpty()) {
        serviceInfo = serviceInfos.get(0);
    } else {
        serviceInfo = null;
    }
}
Also used : Bus(org.apache.cxf.Bus) DestinationFactory(org.apache.cxf.transport.DestinationFactory) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager)

Aggregations

BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)33 Bus (org.apache.cxf.Bus)15 DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)11 WSDLServiceBuilder (org.apache.cxf.wsdl11.WSDLServiceBuilder)8 Before (org.junit.Before)8 BindingInfo (org.apache.cxf.service.model.BindingInfo)7 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)7 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)7 IMocksControl (org.easymock.IMocksControl)7 Definition (javax.wsdl.Definition)6 BusException (org.apache.cxf.BusException)6 BindingFactory (org.apache.cxf.binding.BindingFactory)6 Test (org.junit.Test)6 Service (javax.wsdl.Service)5 WSDLReader (javax.wsdl.xml.WSDLReader)5 QName (javax.xml.namespace.QName)5 SoapBindingInfo (org.apache.cxf.binding.soap.model.SoapBindingInfo)5 JAXRSBindingFactory (org.apache.cxf.jaxrs.JAXRSBindingFactory)5 JAXRSServerFactoryBean (org.apache.cxf.jaxrs.JAXRSServerFactoryBean)4 WSDLFactory (javax.wsdl.factory.WSDLFactory)3