Search in sources :

Example 11 with Binding

use of javax.wsdl.Binding in project carbon-apimgt by wso2.

the class WSDL11SOAPOperationExtractor method getSoapBindingOperations.

/**
 * Retrieves all the operations defined in the provided WSDL definition.
 *
 * @param definition WSDL Definition
 * @return a set of {@link WSDLOperation} defined in the provided WSDL definition
 */
private Set<WSDLSOAPOperation> getSoapBindingOperations(Definition definition) throws APIMgtWSDLException {
    Set<WSDLSOAPOperation> allOperations = new HashSet<>();
    for (Object bindingObj : definition.getAllBindings().values()) {
        if (bindingObj instanceof Binding) {
            Binding binding = (Binding) bindingObj;
            Set<WSDLSOAPOperation> operations = getSOAPBindingOperations(binding);
            allOperations.addAll(operations);
        }
    }
    return allOperations;
}
Also used : SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) WSDLSOAPOperation(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation) HashSet(java.util.HashSet)

Example 12 with Binding

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

the class CorbaObjectReferenceEventProducer method getObjectReferenceBinding.

protected EprMetaData getObjectReferenceBinding(Definition wsdlDef, QName bindingName) {
    EprMetaData info = new EprMetaData();
    Binding wsdlBinding = wsdlDef.getBinding(bindingName);
    // get the list of all bindings and compare their local parts against our name.
    if (wsdlBinding == null && bindingName.getNamespaceURI().isEmpty() && !bindingName.getLocalPart().isEmpty()) {
        Collection<Binding> bindingsCollection = CastUtils.cast(wsdlDef.getBindings().values());
        for (Binding b : bindingsCollection) {
            if (b.getQName().getLocalPart().equals(bindingName.getLocalPart())) {
                wsdlBinding = b;
                break;
            }
        }
    }
    if (wsdlBinding != null) {
        info.setBinding(wsdlBinding);
        info.setCandidateWsdlDef(wsdlDef);
    }
    return info;
}
Also used : Binding(javax.wsdl.Binding) EprMetaData(org.apache.cxf.binding.corba.utils.EprMetaData)

Example 13 with Binding

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

the class CorbaObjectReferenceHelper method getDefaultBinding.

public static Binding getDefaultBinding(Object obj, Definition wsdlDef) {
    LOG.log(Level.FINEST, "Getting binding for a default object reference");
    Collection<Binding> bindings = CastUtils.cast(wsdlDef.getBindings().values());
    for (Binding b : bindings) {
        List<?> extElements = b.getExtensibilityElements();
        // Get the list of all extensibility elements
        for (Iterator<?> extIter = extElements.iterator(); extIter.hasNext(); ) {
            java.lang.Object element = extIter.next();
            // Find a binding type so we can check against its repository ID
            if (element instanceof BindingType) {
                BindingType type = (BindingType) element;
                if (obj._is_a(type.getRepositoryID())) {
                    return b;
                }
            }
        }
    }
    return null;
}
Also used : Binding(javax.wsdl.Binding) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType)

Example 14 with Binding

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

the class WSDLTypes method processObject.

public static CorbaType processObject(Definition definition, XmlSchemaComplexType complex, XmlSchemaAnnotation annotation, QName typeName, QName defaultName, String idlNamespace) throws Exception {
    CorbaType corbaTypeImpl = null;
    if (annotation != null) {
        for (XmlSchemaAnnotationItem item : annotation.getItems()) {
            XmlSchemaAppInfo appInfo = (XmlSchemaAppInfo) item;
            if (appInfo != null) {
                NodeList nlist = appInfo.getMarkup();
                Node node = nlist.item(0);
                String info = node.getNodeValue();
                info = info.trim();
                if ("corba:binding=".equals(info.substring(0, 14))) {
                    String bindingName = info.substring(14);
                    QName bqname = new QName(definition.getTargetNamespace(), bindingName);
                    // Check if the Binding with name already exists
                    Binding binding = null;
                    if (WSDLToCorbaHelper.queryBinding(definition, bqname)) {
                        binding = definition.getBinding(bqname);
                    }
                    if (binding != null) {
                        org.apache.cxf.binding.corba.wsdl.Object obj = new org.apache.cxf.binding.corba.wsdl.Object();
                        PortType portT = binding.getPortType();
                        QName name = new QName(idlNamespace, portT.getQName().getLocalPart(), definition.getPrefix(idlNamespace));
                        obj.setName(name.getLocalPart());
                        obj.setQName(name);
                        QName bName = binding.getQName();
                        obj.setBinding(bName);
                        // get the repository id of the binding.
                        String repId = null;
                        Iterator<?> bindIter = binding.getExtensibilityElements().iterator();
                        while (bindIter.hasNext()) {
                            BindingType type = (BindingType) bindIter.next();
                            repId = type.getRepositoryID();
                        }
                        obj.setRepositoryID(repId);
                        obj.setType(typeName);
                        corbaTypeImpl = obj;
                    } else {
                        // if (isVerboseOn()) {
                        System.out.println("Could not find binding for: " + bqname);
                    // }
                    }
                }
            }
        }
    }
    if (corbaTypeImpl == null) {
        org.apache.cxf.binding.corba.wsdl.Object obj = new org.apache.cxf.binding.corba.wsdl.Object();
        QName name = new QName(idlNamespace, "CORBA.Object", definition.getPrefix(idlNamespace));
        obj.setName(name.getLocalPart());
        obj.setQName(name);
        obj.setRepositoryID("IDL:omg.org/CORBA/Object/1.0");
        obj.setType(typeName);
        corbaTypeImpl = obj;
    }
    return corbaTypeImpl;
}
Also used : Binding(javax.wsdl.Binding) QName(javax.xml.namespace.QName) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) XmlSchemaAnnotationItem(org.apache.ws.commons.schema.XmlSchemaAnnotationItem) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) XmlSchemaAppInfo(org.apache.ws.commons.schema.XmlSchemaAppInfo) PortType(javax.wsdl.PortType)

Example 15 with Binding

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

the class WSDLToCorbaBindingTest method testFixedBindingGeneration.

@Test
public void testFixedBindingGeneration() throws Exception {
    String fileName = getClass().getResource("/wsdl/fixed.wsdl").toString();
    generator.setWsdlFile(fileName);
    generator.addInterfaceName("Y");
    Definition model = generator.generateCORBABinding();
    Document document = writer.getDocument(model);
    Element typemap = getElementNode(document, "corba:typeMapping");
    assertEquals(1, typemap.getElementsByTagName("corba:sequence").getLength());
    assertEquals(5, typemap.getElementsByTagName("corba:fixed").getLength());
    Element bindingElement = getElementNode(document, "binding");
    assertEquals(5, bindingElement.getElementsByTagName("corba:operation").getLength());
    QName bName = new QName("http://schemas.apache.org/idl/fixed.idl", "YCORBABinding", "tns");
    Binding binding = model.getBinding(bName);
    TypeMappingType mapType = (TypeMappingType) model.getExtensibilityElements().get(0);
    Map<String, CorbaType> tmap = new HashMap<>();
    for (CorbaType type : mapType.getStructOrExceptionOrUnion()) {
        tmap.put(type.getName(), type);
    }
    Iterator<?> j = binding.getBindingOperations().iterator();
    while (j.hasNext()) {
        BindingOperation bindingOperation = (BindingOperation) j.next();
        assertEquals("YCORBABinding", binding.getQName().getLocalPart());
        assertEquals(1, bindingOperation.getExtensibilityElements().size());
        checkFixedTypeOne(bindingOperation, tmap);
        bindingOperation = (BindingOperation) j.next();
        checkSequenceType(bindingOperation, tmap);
        bindingOperation = (BindingOperation) j.next();
        checkFixedTypeTwo(bindingOperation, tmap);
        bindingOperation = (BindingOperation) j.next();
        checkFixedTypeThree(bindingOperation, tmap);
        bindingOperation = (BindingOperation) j.next();
        checkFixedTypeFour(bindingOperation, tmap);
    }
}
Also used : WSDLToCorbaBinding(org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaBinding) Binding(javax.wsdl.Binding) BindingOperation(javax.wsdl.BindingOperation) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) Document(org.w3c.dom.Document) Test(org.junit.Test)

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