Search in sources :

Example 6 with ExtensionRegistry

use of javax.wsdl.extensions.ExtensionRegistry in project cxf by apache.

the class ServiceWSDLBuilder method getSchemaImplementation.

private Schema getSchemaImplementation(Definition def) {
    ExtensionRegistry reg = def.getExtensionRegistry();
    ExtensibilityElement extension;
    try {
        extension = reg.createExtension(javax.wsdl.Types.class, WSDLConstants.QNAME_SCHEMA);
    } catch (WSDLException e) {
        throw new RuntimeException("Problem creating schema implementation", e);
    }
    // try to cast the resulting extension:
    try {
        return Schema.class.cast(extension);
    } catch (ClassCastException e) {
        throw new RuntimeException("Schema implementation problem", e);
    }
}
Also used : Types(javax.wsdl.Types) WSDLException(javax.wsdl.WSDLException) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) ExtensionRegistry(javax.wsdl.extensions.ExtensionRegistry)

Example 7 with ExtensionRegistry

use of javax.wsdl.extensions.ExtensionRegistry 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 8 with ExtensionRegistry

use of javax.wsdl.extensions.ExtensionRegistry in project cxf by apache.

the class SoapTransportFactory method createSoapExtensors.

private void createSoapExtensors(Bus bus, EndpointInfo ei, SoapBindingInfo bi, boolean isSoap12) {
    try {
        String address = ei.getAddress();
        if (address == null) {
            address = "http://localhost:9090";
        }
        ExtensionRegistry registry = bus.getExtension(WSDLManager.class).getExtensionRegistry();
        SoapAddress soapAddress = SOAPBindingUtil.createSoapAddress(registry, isSoap12);
        soapAddress.setLocationURI(address);
        ei.addExtensor(soapAddress);
    } catch (WSDLException e) {
        e.printStackTrace();
    }
}
Also used : WSDLException(javax.wsdl.WSDLException) SoapAddress(org.apache.cxf.binding.soap.wsdl.extensions.SoapAddress) WSDLManager(org.apache.cxf.wsdl.WSDLManager) ExtensionRegistry(javax.wsdl.extensions.ExtensionRegistry)

Aggregations

ExtensionRegistry (javax.wsdl.extensions.ExtensionRegistry)8 WSDLException (javax.wsdl.WSDLException)4 Definition (javax.wsdl.Definition)3 WSDLManager (org.apache.cxf.wsdl.WSDLManager)3 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)2 UnknownExtensibilityElement (javax.wsdl.extensions.UnknownExtensibilityElement)2 WSDLFactory (javax.wsdl.factory.WSDLFactory)2 PopulatedExtensionRegistry (com.ibm.wsdl.extensions.PopulatedExtensionRegistry)1 Map (java.util.Map)1 Binding (javax.wsdl.Binding)1 PortType (javax.wsdl.PortType)1 Types (javax.wsdl.Types)1 WSDLReader (javax.wsdl.xml.WSDLReader)1 QName (javax.xml.namespace.QName)1 WebServiceException (javax.xml.ws.WebServiceException)1 Addressing (javax.xml.ws.soap.Addressing)1 Bus (org.apache.cxf.Bus)1 SoapHeaderInfo (org.apache.cxf.binding.soap.model.SoapHeaderInfo)1 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)1 SoapAddress (org.apache.cxf.binding.soap.wsdl.extensions.SoapAddress)1