Search in sources :

Example 21 with WSDLFactory

use of javax.wsdl.factory.WSDLFactory in project cxf by apache.

the class WSDLServiceFactory method create.

public Service create() {
    List<ServiceInfo> services;
    if (serviceName == null) {
        try {
            WSDLServiceBuilder builder = new WSDLServiceBuilder(getBus());
            builder.setAllowElementRefs(allowRefs);
            services = builder.buildServices(definition);
        } catch (XmlSchemaException ex) {
            throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex);
        }
        if (services.isEmpty()) {
            throw new ServiceConstructionException(new Message("NO_SERVICE_EXC", LOG));
        }
        // @@TODO  - this isn't good, need to return all the services
        serviceName = services.get(0).getName();
        // get all the service info's that match that first one.
        Iterator<ServiceInfo> it = services.iterator();
        while (it.hasNext()) {
            if (!it.next().getName().equals(serviceName)) {
                it.remove();
            }
        }
    } else {
        javax.wsdl.Service wsdlService = definition.getService(serviceName);
        if (wsdlService == null) {
            if ((!PartialWSDLProcessor.isServiceExisted(definition, serviceName)) && (!PartialWSDLProcessor.isBindingExisted(definition, serviceName)) && (PartialWSDLProcessor.isPortTypeExisted(definition, serviceName))) {
                try {
                    Map<QName, PortType> portTypes = CastUtils.cast(definition.getAllPortTypes());
                    String existPortName = null;
                    PortType portType = null;
                    for (Map.Entry<QName, PortType> entry : portTypes.entrySet()) {
                        existPortName = entry.getKey().getLocalPart();
                        if (serviceName.getLocalPart().contains(existPortName)) {
                            portType = entry.getValue();
                            break;
                        }
                    }
                    WSDLFactory factory = WSDLFactory.newInstance();
                    ExtensionRegistry extReg = factory.newPopulatedExtensionRegistry();
                    Binding binding = PartialWSDLProcessor.doAppendBinding(definition, existPortName, portType, extReg);
                    definition.addBinding(binding);
                    wsdlService = PartialWSDLProcessor.doAppendService(definition, existPortName, extReg, binding);
                    definition.addService(wsdlService);
                } catch (Exception e) {
                    throw new ServiceConstructionException(new Message("NO_SUCH_SERVICE_EXC", LOG, serviceName));
                }
            } else {
                throw new ServiceConstructionException(new Message("NO_SUCH_SERVICE_EXC", LOG, serviceName));
            }
        }
        try {
            services = new WSDLServiceBuilder(getBus()).buildServices(definition, wsdlService, endpointName);
            if (services.isEmpty()) {
                throw new ServiceConstructionException(new Message("NO_SUCH_ENDPOINT_EXC", LOG, endpointName));
            }
        } catch (XmlSchemaException ex) {
            throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex);
        }
    }
    ServiceImpl service = new ServiceImpl(services);
    setService(service);
    return service;
}
Also used : Binding(javax.wsdl.Binding) Message(org.apache.cxf.common.i18n.Message) XmlSchemaException(org.apache.ws.commons.schema.XmlSchemaException) QName(javax.xml.namespace.QName) ServiceImpl(org.apache.cxf.service.ServiceImpl) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException) XmlSchemaException(org.apache.ws.commons.schema.XmlSchemaException) WSDLException(javax.wsdl.WSDLException) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException) ExtensionRegistry(javax.wsdl.extensions.ExtensionRegistry) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) WSDLFactory(javax.wsdl.factory.WSDLFactory) Map(java.util.Map) PortType(javax.wsdl.PortType)

Example 22 with WSDLFactory

use of javax.wsdl.factory.WSDLFactory in project cxf by apache.

the class OASISCatalogTest method testWSDLLocatorWithDefaultCatalog.

@Test
public void testWSDLLocatorWithDefaultCatalog() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/catalog/hello_world_services.wsdl");
    assertNotNull(wsdl);
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    CatalogWSDLLocator wsdlLocator = new CatalogWSDLLocator(wsdl.toString(), OASISCatalogManager.getCatalogManager(null));
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    wsdlReader.readWSDL(wsdlLocator);
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) CatalogWSDLLocator(org.apache.cxf.wsdl11.CatalogWSDLLocator) URL(java.net.URL) WSDLReader(javax.wsdl.xml.WSDLReader) Test(org.junit.Test)

Example 23 with WSDLFactory

use of javax.wsdl.factory.WSDLFactory in project cxf by apache.

the class OASISCatalogTest method testWSDLLocatorWithoutCatalog.

@Test
public void testWSDLLocatorWithoutCatalog() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/catalog/hello_world_services.wsdl");
    assertNotNull(wsdl);
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    OASISCatalogManager catalog = new OASISCatalogManager();
    CatalogWSDLLocator wsdlLocator = new CatalogWSDLLocator(wsdl.toString(), catalog);
    try {
        wsdlReader.readWSDL(wsdlLocator);
        fail("Test did not fail as expected");
    } catch (WSDLException e) {
    // ignore
    }
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLException(javax.wsdl.WSDLException) OASISCatalogManager(org.apache.cxf.catalog.OASISCatalogManager) CatalogWSDLLocator(org.apache.cxf.wsdl11.CatalogWSDLLocator) URL(java.net.URL) WSDLReader(javax.wsdl.xml.WSDLReader) Test(org.junit.Test)

Example 24 with WSDLFactory

use of javax.wsdl.factory.WSDLFactory in project tesb-studio-se by Talend.

the class WSDLUtils method getDefinition.

// public static Definition getDefinition(String pathToWsdl) throws CoreException {
// try {
// WSDLFactory wsdlFactory = WSDLFactory.newInstance();
// WSDLReader newWSDLReader = wsdlFactory.newWSDLReader();
// 
// newWSDLReader.setExtensionRegistry(wsdlFactory.newPopulatedExtensionRegistry());
// newWSDLReader.setFeature(com.ibm.wsdl.Constants.FEATURE_VERBOSE, false);
// return newWSDLReader.readWSDL(pathToWsdl);
// } catch (WSDLException e) {
// throw new CoreException(StatusUtil.newStatus(IStatus.ERROR, e.getLocalizedMessage(), e));
// }
// }
public static Definition getDefinition(IFile pathToWsdl) throws CoreException {
    try {
        WSDLFactory wsdlFactory = WSDLFactory.newInstance();
        WSDLReader newWSDLReader = wsdlFactory.newWSDLReader();
        newWSDLReader.setExtensionRegistry(wsdlFactory.newPopulatedExtensionRegistry());
        newWSDLReader.setFeature(com.ibm.wsdl.Constants.FEATURE_VERBOSE, false);
        return newWSDLReader.readWSDL(pathToWsdl.getLocationURI().toString());
    } catch (WSDLException e) {
        throw getCoreException(null, e);
    }
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLException(javax.wsdl.WSDLException) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 25 with WSDLFactory

use of javax.wsdl.factory.WSDLFactory in project jbossws-cxf by jbossws.

the class JBWS2150TestCase method getWSDLDefinition.

private Definition getWSDLDefinition(String wsdlLocation) throws Exception {
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.importDocuments", false);
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    Definition definition = wsdlReader.readWSDL(null, wsdlLocation);
    return definition;
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) Definition(javax.wsdl.Definition) WSDLReader(javax.wsdl.xml.WSDLReader)

Aggregations

WSDLFactory (javax.wsdl.factory.WSDLFactory)28 WSDLReader (javax.wsdl.xml.WSDLReader)25 Definition (javax.wsdl.Definition)13 URL (java.net.URL)6 Service (javax.wsdl.Service)5 WSDLException (javax.wsdl.WSDLException)5 QName (javax.xml.namespace.QName)4 ArrayList (java.util.ArrayList)3 Port (javax.wsdl.Port)3 ExtensionRegistry (javax.wsdl.extensions.ExtensionRegistry)3 Bus (org.apache.cxf.Bus)3 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)3 DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)3 WSDLManager (org.apache.cxf.wsdl.WSDLManager)3 CatalogWSDLLocator (org.apache.cxf.wsdl11.CatalogWSDLLocator)3 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 HashMap (java.util.HashMap)2 Hashtable (java.util.Hashtable)2