Search in sources :

Example 1 with BindingType

use of org.apache.cxf.binding.corba.wsdl.BindingType 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 2 with BindingType

use of org.apache.cxf.binding.corba.wsdl.BindingType in project cxf by apache.

the class PortTypeVisitor method createBinding.

public Binding createBinding(String scopedPortTypeName) {
    StringBuilder bname = new StringBuilder();
    bname.append(scopedPortTypeName).append("CORBABinding");
    QName bqname = new QName(rootDefinition.getTargetNamespace(), bname.toString());
    int count = 0;
    while (queryBinding(bqname)) {
        bname.append(count);
        bqname = new QName(rootDefinition.getTargetNamespace(), bname.toString());
    }
    Binding binding = rootDefinition.createBinding();
    binding.setPortType(portType);
    binding.setQName(bqname);
    try {
        BindingType bindingType = (BindingType) extReg.createExtension(Binding.class, CorbaConstants.NE_CORBA_BINDING);
        String pragmaPrefix = (this.getWsdlVisitor().getPragmaPrefix() != null && this.getWsdlVisitor().getPragmaPrefix().length() > 0) ? this.getWsdlVisitor().getPragmaPrefix() + "/" : "";
        bindingType.setRepositoryID(CorbaConstants.REPO_STRING + pragmaPrefix + scopedPortTypeName.replace('.', '/') + CorbaConstants.IDL_VERSION);
        binding.addExtensibilityElement((ExtensibilityElement) bindingType);
    } catch (WSDLException ex) {
        throw new RuntimeException(ex);
    }
    binding.setUndefined(false);
    rootDefinition.addBinding(binding);
    return binding;
}
Also used : Binding(javax.wsdl.Binding) WSDLException(javax.wsdl.WSDLException) QName(javax.xml.namespace.QName) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType)

Example 3 with BindingType

use of org.apache.cxf.binding.corba.wsdl.BindingType in project cxf by apache.

the class WSDLToCorbaBinding method generateCORBABinding.

private Binding generateCORBABinding(Definition definition, PortType portType) throws Exception {
    QName bqname;
    if (extReg == null) {
        extReg = def.getExtensionRegistry();
    }
    bindingNames = new ArrayList<>();
    String interfaceName = portType.getQName().getLocalPart();
    String bname = getMappedBindingName(interfaceName);
    String prefix = definition.getPrefix(definition.getTargetNamespace());
    if (prefix == null) {
        prefix = "";
    }
    if (bname == null && !allbindings) {
        bname = bindingName;
    }
    if (bname == null) {
        bname = mangleInterfaceName(interfaceName) + "CORBABinding";
        setBindingName(bname);
        bqname = new QName(definition.getTargetNamespace(), bname, prefix);
        int count = 0;
        StringBuilder builder = new StringBuilder(bname);
        while (WSDLToCorbaHelper.queryBinding(definition, bqname)) {
            builder.append(count);
            bqname = new QName(definition.getTargetNamespace(), builder.toString(), prefix);
        }
        bname = builder.toString();
    } else {
        bqname = new QName(definition.getTargetNamespace(), bname, prefix);
        // Check if the Binding with name already exists
        if (WSDLToCorbaHelper.queryBinding(definition, bqname)) {
            String msgStr = "Binding " + bqname.getLocalPart() + " already exists in WSDL.";
            org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
            throw new ToolException(msg.toString());
        }
    }
    // jwsdl model should have all other bindings in it.
    String pfx = definition.getPrefix(CorbaConstants.NU_WSDL_CORBA);
    if (pfx == null) {
        pfx = "corba";
        def.addNamespace(pfx, CorbaConstants.NU_WSDL_CORBA);
    }
    Binding binding = def.createBinding();
    binding.setPortType(portType);
    binding.setQName(bqname);
    bindingNames.add(bname);
    mapBindingToInterface(portType.getQName().getLocalPart(), bname);
    addCorbaTypeMap(def);
    try {
        BindingType bindingType = (BindingType) extReg.createExtension(Binding.class, CorbaConstants.NE_CORBA_BINDING);
        bindingType.setRepositoryID(WSDLToCorbaHelper.REPO_STRING + binding.getPortType().getQName().getLocalPart().replace('.', '/') + WSDLToCorbaHelper.IDL_VERSION);
        binding.addExtensibilityElement((ExtensibilityElement) bindingType);
    } catch (WSDLException ex) {
        ex.printStackTrace();
    }
    try {
        addBindingOperations(def, portType, binding);
        binding.setUndefined(false);
        definition.addBinding(binding);
    } catch (Exception ex) {
        binding.setUndefined(true);
    }
    cleanUpTypeMap(typeMappingType);
    return binding;
}
Also used : Binding(javax.wsdl.Binding) WSDLException(javax.wsdl.WSDLException) QName(javax.xml.namespace.QName) WSDLException(javax.wsdl.WSDLException) ToolException(org.apache.cxf.tools.common.ToolException) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) ToolException(org.apache.cxf.tools.common.ToolException)

Example 4 with BindingType

use of org.apache.cxf.binding.corba.wsdl.BindingType 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 5 with BindingType

use of org.apache.cxf.binding.corba.wsdl.BindingType in project cxf by apache.

the class WSDLToCorbaBindingTest method testMultipartCORBABindingGeneration.

@Test
public void testMultipartCORBABindingGeneration() throws Exception {
    String fileName = getClass().getResource("/wsdl/multipart.wsdl").toString();
    generator.setWsdlFile(fileName);
    generator.addInterfaceName("Test.MultiPart");
    Definition model = generator.generateCORBABinding();
    QName bName = new QName("http://schemas.apache.org/tests", "Test.MultiPartCORBABinding", "tns");
    Binding binding = model.getBinding(bName);
    assertNotNull(binding);
    assertEquals("Test.MultiPartCORBABinding", binding.getQName().getLocalPart());
    assertEquals("Test.MultiPart", binding.getPortType().getQName().getLocalPart());
    assertEquals(1, binding.getExtensibilityElements().size());
    assertEquals(32, binding.getBindingOperations().size());
    List<ExtensibilityElement> extElements = getExtensibilityElements(binding);
    ExtensibilityElement extElement = extElements.get(0);
    if ("binding".equals(extElement.getElementType().getLocalPart())) {
        BindingType bindingType = (BindingType) extElement;
        assertEquals(bindingType.getRepositoryID(), "IDL:Test/MultiPart:1.0");
    }
    getStringAttributeTest(binding);
    getTestIdTest(binding);
    setTestIdTest(binding);
    testVoidTest(binding);
    testPrimitiveTypeTest(binding, "test_short", CorbaConstants.NT_CORBA_SHORT);
    testPrimitiveTypeTest(binding, "test_long", CorbaConstants.NT_CORBA_LONG);
    testPrimitiveTypeTest(binding, "test_longlong", CorbaConstants.NT_CORBA_LONGLONG);
    testPrimitiveTypeTest(binding, "test_ushort", CorbaConstants.NT_CORBA_USHORT);
    testPrimitiveTypeTest(binding, "test_ulong", CorbaConstants.NT_CORBA_ULONG);
    testPrimitiveTypeTest(binding, "test_ulonglong", CorbaConstants.NT_CORBA_ULONGLONG);
    testPrimitiveTypeTest(binding, "test_float", CorbaConstants.NT_CORBA_FLOAT);
    testPrimitiveTypeTest(binding, "test_double", CorbaConstants.NT_CORBA_DOUBLE);
    testPrimitiveTypeTest(binding, "test_octet", CorbaConstants.NT_CORBA_OCTET);
    testPrimitiveTypeTest(binding, "test_boolean", CorbaConstants.NT_CORBA_BOOLEAN);
    testPrimitiveTypeTest(binding, "test_char", CorbaConstants.NT_CORBA_CHAR);
    testPrimitiveTypeTest(binding, "test_integer", CorbaConstants.NT_CORBA_LONGLONG);
    testPrimitiveTypeTest(binding, "test_nonNegativeInteger", CorbaConstants.NT_CORBA_ULONGLONG);
    testPrimitiveTypeTest(binding, "test_positiveInteger", CorbaConstants.NT_CORBA_ULONGLONG);
    testPrimitiveTypeTest(binding, "test_negativeInteger", CorbaConstants.NT_CORBA_LONGLONG);
    testPrimitiveTypeTest(binding, "test_normalizedString", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_token", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_language", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_Name", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_NCName", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_ID", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_anyURI", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_nick_name", CorbaConstants.NT_CORBA_STRING);
}
Also used : WSDLToCorbaBinding(org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaBinding) Binding(javax.wsdl.Binding) QName(javax.xml.namespace.QName) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) Definition(javax.wsdl.Definition) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Test(org.junit.Test)

Aggregations

BindingType (org.apache.cxf.binding.corba.wsdl.BindingType)14 Binding (javax.wsdl.Binding)12 QName (javax.xml.namespace.QName)9 Definition (javax.wsdl.Definition)7 BindingOperation (javax.wsdl.BindingOperation)5 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)5 OperationType (org.apache.cxf.binding.corba.wsdl.OperationType)5 WSDLToCorbaBinding (org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaBinding)5 Test (org.junit.Test)5 ToolException (org.apache.cxf.tools.common.ToolException)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 PortType (javax.wsdl.PortType)2 WSDLException (javax.wsdl.WSDLException)2 ParamType (org.apache.cxf.binding.corba.wsdl.ParamType)2 IdlString (org.apache.cxf.tools.corba.common.idltypes.IdlString)2 WSDLToIDLAction (org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction)2 AST (antlr.collections.AST)1 PrintWriter (java.io.PrintWriter)1 List (java.util.List)1