Search in sources :

Example 11 with BindingType

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

the class CorbaDSIServant method init.

public void init(ORB theOrb, POA poa, CorbaDestination dest, MessageObserver observer, CorbaTypeMap map) {
    orb = theOrb;
    servantPOA = poa;
    destination = dest;
    incomingObserver = observer;
    typeMap = map;
    // Get the list of interfaces that this servant will support
    try {
        BindingType bindType = destination.getBindingInfo().getExtensor(BindingType.class);
        if (bindType == null) {
            throw new CorbaBindingException("Unable to determine corba binding information");
        }
        List<String> bases = bindType.getBases();
        interfaces = new ArrayList<>();
        interfaces.add(bindType.getRepositoryID());
        for (Iterator<String> iter = bases.iterator(); iter.hasNext(); ) {
            interfaces.add(iter.next());
        }
    } catch (java.lang.Exception ex) {
        LOG.log(Level.SEVERE, "Couldn't initialize the corba DSI servant");
        throw new CorbaBindingException(ex);
    }
    // Build the list of CORBA operations and the WSDL operations they map to.  Note that
    // the WSDL operation name may not always match the CORBA operation name.
    BindingInfo bInfo = destination.getBindingInfo();
    Iterator<BindingOperationInfo> i = bInfo.getOperations().iterator();
    operationMap = new HashMap<>(bInfo.getOperations().size());
    while (i.hasNext()) {
        BindingOperationInfo bopInfo = i.next();
        OperationType opType = bopInfo.getExtensor(OperationType.class);
        if (opType != null) {
            operationMap.put(opType.getName(), bopInfo.getName());
        }
    }
}
Also used : CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) BindingInfo(org.apache.cxf.service.model.BindingInfo) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType)

Example 12 with BindingType

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

the class CorbaObjectReferenceHelper method getBindingForTypeId.

public static EprMetaData getBindingForTypeId(String repId, Definition wsdlDef) {
    LOG.log(Level.FINE, "RepositoryId " + repId + ", wsdl namespace " + wsdlDef.getTargetNamespace());
    EprMetaData ret = new EprMetaData();
    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 (repId.equals(type.getRepositoryID())) {
                    ret.setCandidateWsdlDef(wsdlDef);
                    ret.setBinding(b);
                    return ret;
                }
            }
        }
    }
    if (!ret.isValid()) {
        // recursivly check imports
        Iterator<?> importLists = wsdlDef.getImports().values().iterator();
        while (importLists.hasNext()) {
            List<?> imports = (List<?>) importLists.next();
            for (java.lang.Object imp : imports) {
                if (imp instanceof Import) {
                    Definition importDef = ((Import) imp).getDefinition();
                    LOG.log(Level.INFO, "Following import " + importDef.getDocumentBaseURI());
                    ret = getBindingForTypeId(repId, importDef);
                    if (ret.isValid()) {
                        return ret;
                    }
                }
            }
        }
    }
    return ret;
}
Also used : Binding(javax.wsdl.Binding) Import(javax.wsdl.Import) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) Definition(javax.wsdl.Definition) List(java.util.List)

Example 13 with BindingType

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

the class WSDLToCorbaBindingTest method testCORBABindingGeneration.

@Test
public void testCORBABindingGeneration() throws Exception {
    String fileName = getClass().getResource("/wsdl/simpleList.wsdl").toString();
    generator.setWsdlFile(fileName);
    generator.addInterfaceName("BasePortType");
    Definition model = generator.generateCORBABinding();
    QName bName = new QName("http://schemas.apache.org/tests", "BaseCORBABinding", "tns");
    Binding binding = model.getBinding(bName);
    assertNotNull(binding);
    assertEquals("BaseCORBABinding", binding.getQName().getLocalPart());
    assertEquals("BasePortType", binding.getPortType().getQName().getLocalPart());
    assertEquals(1, binding.getExtensibilityElements().size());
    assertEquals(1, binding.getBindingOperations().size());
    for (ExtensibilityElement extElement : getExtensibilityElements(binding)) {
        if (extElement.getElementType().getLocalPart().equals("binding")) {
            BindingType bindingType = (BindingType) extElement;
            assertEquals(bindingType.getRepositoryID(), "IDL:BasePortType:1.0");
        }
    }
    Iterator<?> j = binding.getBindingOperations().iterator();
    while (j.hasNext()) {
        BindingOperation bindingOperation = (BindingOperation) j.next();
        assertEquals(1, bindingOperation.getExtensibilityElements().size());
        assertEquals(bindingOperation.getBindingInput().getName(), "echoString");
        assertEquals(bindingOperation.getBindingOutput().getName(), "echoStringResponse");
        for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
            if (extElement.getElementType().getLocalPart().equals("operation")) {
                OperationType corbaOpType = (OperationType) extElement;
                assertEquals(corbaOpType.getName(), "echoString");
                assertEquals(3, corbaOpType.getParam().size());
                assertEquals(corbaOpType.getReturn().getName(), "return");
                assertEquals(corbaOpType.getReturn().getIdltype(), CorbaConstants.NT_CORBA_STRING);
                assertEquals(corbaOpType.getParam().get(0).getName(), "x");
                assertEquals(corbaOpType.getParam().get(0).getMode().value(), "in");
                QName qname = new QName("http://schemas.apache.org/tests/corba/typemap/", "StringEnum1", "ns1");
                assertEquals(corbaOpType.getParam().get(0).getIdltype(), qname);
            }
        }
    }
}
Also used : WSDLToCorbaBinding(org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaBinding) Binding(javax.wsdl.Binding) BindingOperation(javax.wsdl.BindingOperation) QName(javax.xml.namespace.QName) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) Definition(javax.wsdl.Definition) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Test(org.junit.Test)

Example 14 with BindingType

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

the class WSDLToCorbaBindingTest method testExceptionCORBABindingGeneration.

// next story to add Fault support
@Test
public void testExceptionCORBABindingGeneration() throws Exception {
    String fileName = getClass().getResource("/wsdl/exceptions.wsdl").toString();
    generator.setWsdlFile(fileName);
    generator.addInterfaceName("TestException.ExceptionTest");
    Definition model = generator.generateCORBABinding();
    QName bName = new QName("http://schemas.apache.org/idl/exceptions.idl", "TestException.ExceptionTestCORBABinding", "tns");
    Binding binding = model.getBinding(bName);
    assertNotNull(binding);
    assertEquals("TestException.ExceptionTestCORBABinding", binding.getQName().getLocalPart());
    assertEquals("TestException.ExceptionTest", binding.getPortType().getQName().getLocalPart());
    assertEquals(1, binding.getExtensibilityElements().size());
    assertEquals(1, binding.getBindingOperations().size());
    for (ExtensibilityElement extElement : getExtensibilityElements(binding)) {
        if (extElement.getElementType().getLocalPart().equals("binding")) {
            BindingType bindingType = (BindingType) extElement;
            assertEquals(bindingType.getRepositoryID(), "IDL:TestException/ExceptionTest:1.0");
        }
    }
    Iterator<?> j = binding.getBindingOperations().iterator();
    while (j.hasNext()) {
        BindingOperation bindingOperation = (BindingOperation) j.next();
        assertEquals(1, bindingOperation.getExtensibilityElements().size());
        assertEquals(bindingOperation.getBindingInput().getName(), "review_data");
        assertEquals(bindingOperation.getBindingOutput().getName(), "review_dataResponse");
        Iterator<?> f = bindingOperation.getBindingFaults().values().iterator();
        boolean hasBadRecord = false;
        boolean hasMyException = false;
        while (f.hasNext()) {
            BindingFault bindingFault = (BindingFault) f.next();
            if ("TestException.BadRecord".equals(bindingFault.getName())) {
                hasBadRecord = true;
            } else if ("MyException".equals(bindingFault.getName())) {
                hasMyException = true;
            } else {
                fail("Unexpected BindingFault: " + bindingFault.getName());
            }
        }
        assertTrue("Did not get expected TestException.BadRecord", hasBadRecord);
        assertTrue("Did not get expected MyException", hasMyException);
        for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
            if (extElement.getElementType().getLocalPart().equals("operation")) {
                OperationType corbaOpType = (OperationType) extElement;
                assertEquals(corbaOpType.getName(), "review_data");
                assertEquals(1, corbaOpType.getParam().size());
                assertEquals(2, corbaOpType.getRaises().size());
                hasBadRecord = false;
                hasMyException = false;
                for (int k = 0; k < corbaOpType.getRaises().size(); k++) {
                    String localPart = corbaOpType.getRaises().get(k).getException().getLocalPart();
                    if ("TestException.BadRecord".equals(localPart)) {
                        hasBadRecord = true;
                    } else if ("MyExceptionType".equals(localPart)) {
                        hasMyException = true;
                    } else {
                        fail("Unexpected Raises: " + localPart);
                    }
                }
                assertTrue("Did not find expected TestException.BadRecord", hasBadRecord);
                assertTrue("Did not find expected MyException", hasMyException);
            }
        }
    }
}
Also used : WSDLToCorbaBinding(org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaBinding) Binding(javax.wsdl.Binding) BindingOperation(javax.wsdl.BindingOperation) BindingFault(javax.wsdl.BindingFault) QName(javax.xml.namespace.QName) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) Definition(javax.wsdl.Definition) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) 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 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 IdlException (org.apache.cxf.tools.corba.common.idltypes.IdlException)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 List (java.util.List)1 BindingFault (javax.wsdl.BindingFault)1