Search in sources :

Example 41 with Binding

use of javax.wsdl.Binding in project cxf by apache.

the class SOAPBindingUtil method createSoapBinding.

public static SOAPBinding createSoapBinding(ExtensionRegistry extReg, boolean isSOAP12) throws WSDLException {
    final ExtensibilityElement extElement;
    if (isSOAP12) {
        extElement = extReg.createExtension(Binding.class, new QName(WSDLConstants.NS_SOAP12, "binding"));
        ((SOAP12Binding) extElement).setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
    } else {
        extElement = extReg.createExtension(Binding.class, new QName(WSDLConstants.NS_SOAP11, "binding"));
        ((SOAPBinding) extElement).setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
    }
    return getSoapBinding(extElement);
}
Also used : SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) QName(javax.xml.namespace.QName) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Example 42 with Binding

use of javax.wsdl.Binding in project cxf by apache.

the class PartialWSDLProcessor method doAppendBinding.

public static Binding doAppendBinding(Definition wsdlDefinition, String name, PortType portType, ExtensionRegistry extReg) throws Exception {
    Binding binding = wsdlDefinition.createBinding();
    binding.setQName(new QName(wsdlDefinition.getTargetNamespace(), name + bindingName));
    binding.setUndefined(false);
    binding.setPortType(portType);
    setSoapBindingExtElement(wsdlDefinition, binding, extReg);
    addBindingOperation(wsdlDefinition, portType, binding, extReg);
    return binding;
}
Also used : SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) Binding(javax.wsdl.Binding) QName(javax.xml.namespace.QName)

Example 43 with Binding

use of javax.wsdl.Binding in project cxf by apache.

the class PartialWSDLProcessor method isBindingExisted.

public static boolean isBindingExisted(Definition wsdlDefinition, QName name) {
    Map<QName, Binding> bindings = CastUtils.cast(wsdlDefinition.getAllBindings());
    Binding binding = null;
    if (bindings == null || bindings.isEmpty()) {
        return false;
    }
    try {
        for (Entry<QName, Binding> entry : bindings.entrySet()) {
            if (entry.getKey().getLocalPart().contains(name.getLocalPart())) {
                binding = entry.getValue();
                break;
            }
        }
    } catch (Exception e) {
        binding = null;
    }
    return binding != null;
}
Also used : SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) Binding(javax.wsdl.Binding) QName(javax.xml.namespace.QName)

Example 44 with Binding

use of javax.wsdl.Binding in project cxf by apache.

the class WSDLServiceBuilder method buildMockServices.

public List<ServiceInfo> buildMockServices(Definition d) {
    List<ServiceInfo> serviceList = new ArrayList<>();
    List<Definition> defList = new ArrayList<>();
    defList.add(d);
    parseImports(d, defList);
    for (Definition def : defList) {
        for (Iterator<?> ite = def.getPortTypes().entrySet().iterator(); ite.hasNext(); ) {
            Entry<?, ?> entry = (Entry<?, ?>) ite.next();
            PortType portType = def.getPortType((QName) entry.getKey());
            ServiceInfo serviceInfo = this.buildMockService(def, portType);
            serviceList.add(serviceInfo);
            for (Iterator<?> it2 = d.getAllBindings().values().iterator(); it2.hasNext(); ) {
                Binding b = (Binding) it2.next();
                if (b.getPortType() == portType) {
                    this.buildBinding(serviceInfo, b);
                    break;
                }
            }
        }
        if (def.getPortTypes().isEmpty()) {
            DescriptionInfo description = new DescriptionInfo();
            if (recordOriginal) {
                description.setProperty(WSDL_DEFINITION, def);
            }
            description.setName(def.getQName());
            description.setBaseURI(def.getDocumentBaseURI());
            copyExtensors(description, def.getExtensibilityElements());
            copyExtensionAttributes(description, def);
            ServiceInfo service = new ServiceInfo();
            service.setDescription(description);
            if (recordOriginal) {
                service.setProperty(WSDL_DEFINITION, def);
            }
            getSchemas(def, service);
            service.setProperty(WSDL_SCHEMA_ELEMENT_LIST, this.schemaList);
            serviceList.add(service);
        }
    }
    return serviceList;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) Definition(javax.wsdl.Definition) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo) PortType(javax.wsdl.PortType)

Example 45 with Binding

use of javax.wsdl.Binding in project cxf by apache.

the class WSDLServiceBuilder method buildServices.

private List<ServiceInfo> buildServices(Definition def, Service serv, QName endpointName, DescriptionInfo d) {
    Map<QName, ServiceInfo> services = new LinkedHashMap<>();
    DescriptionInfo description = d;
    if (null == description) {
        description = new DescriptionInfo();
        if (recordOriginal) {
            description.setProperty(WSDL_DEFINITION, def);
        }
        description.setName(def.getQName());
        description.setBaseURI(def.getDocumentBaseURI());
        copyExtensors(description, def.getExtensibilityElements());
        copyExtensionAttributes(description, def);
        Set<Definition> done = new HashSet<>();
        done.add(def);
        Collection<List<Import>> values = CastUtils.cast(def.getImports().values());
        for (List<Import> imports : values) {
            for (Import imp : imports) {
                if (!done.contains(imp.getDefinition())) {
                    done.add(imp.getDefinition());
                    copyExtensors(description, imp.getExtensibilityElements());
                    copyExtensionAttributes(description, imp);
                    copyExtensors(description, imp.getDefinition().getExtensibilityElements());
                    copyExtensionAttributes(description, imp.getDefinition());
                }
            }
        }
    }
    for (Port port : cast(serv.getPorts().values(), Port.class)) {
        if (endpointName != null && !endpointName.getLocalPart().equals(port.getName())) {
            continue;
        }
        Binding binding = port.getBinding();
        PortType bindingPt = binding.getPortType();
        if (bindingPt == null) {
            org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("BINDING_MISSING_TYPE", LOG, binding.getQName());
            throw new WSDLRuntimeException(msg);
        }
        // TODO: wsdl4j's bug. if there is recursive import,
        // wsdl4j can not get operation input message
        PortType pt = def.getPortType(bindingPt.getQName());
        if (pt == null) {
            pt = bindingPt;
        }
        ServiceInfo service = services.get(pt.getQName());
        if (service == null) {
            service = new ServiceInfo();
            service.setDescription(description);
            description.getDescribed().add(service);
            if (recordOriginal) {
                service.setProperty(WSDL_DEFINITION, def);
                service.setProperty(WSDL_SERVICE, serv);
            }
            getSchemas(def, service);
            copyDocumentation(service, serv);
            service.setProperty(WSDL_SCHEMA_ELEMENT_LIST, this.schemaList);
            service.setTargetNamespace(def.getTargetNamespace());
            service.setName(serv.getQName());
            copyExtensors(service, serv.getExtensibilityElements());
            copyExtensionAttributes(service, serv);
            buildInterface(service, pt);
            services.put(pt.getQName(), service);
        }
        BindingInfo bi = service.getBinding(binding.getQName());
        if (bi == null) {
            bi = buildBinding(service, binding);
        }
        buildEndpoint(service, bi, port);
    }
    return new ArrayList<>(services.values());
}
Also used : Import(javax.wsdl.Import) Message(javax.wsdl.Message) Port(javax.wsdl.Port) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) List(java.util.List) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo) PortType(javax.wsdl.PortType)

Aggregations

Binding (javax.wsdl.Binding)69 QName (javax.xml.namespace.QName)39 BindingOperation (javax.wsdl.BindingOperation)28 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)22 Definition (javax.wsdl.Definition)18 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)18 Test (org.junit.Test)18 Port (javax.wsdl.Port)17 Operation (javax.wsdl.Operation)16 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)15 PortType (javax.wsdl.PortType)14 Service (javax.wsdl.Service)12 BindingType (org.apache.cxf.binding.corba.wsdl.BindingType)12 ToolException (org.apache.cxf.tools.common.ToolException)12 File (java.io.File)9 ArrayList (java.util.ArrayList)8 BindingInput (javax.wsdl.BindingInput)8 Message (javax.wsdl.Message)8 Map (java.util.Map)7 HashSet (java.util.HashSet)6