Search in sources :

Example 1 with TypeMappingType

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

the class CorbaConduitTest method testBuildExceptionListWithExceptions.

@Test
public void testBuildExceptionListWithExceptions() throws Exception {
    CorbaConduit conduit = setupCorbaConduit(false);
    Message msg = new MessageImpl();
    CorbaMessage message = new CorbaMessage(msg);
    TestUtils testUtils = new TestUtils();
    CorbaDestination destination = testUtils.getExceptionTypesTestDestination();
    EndpointInfo endpointInfo2 = destination.getEndPointInfo();
    QName name = new QName("http://schemas.apache.org/idl/except", "review_data", "");
    BindingOperationInfo bInfo = destination.getBindingInfo().getOperation(name);
    OperationType opType = bInfo.getExtensor(OperationType.class);
    CorbaTypeMap typeMap = null;
    List<TypeMappingType> corbaTypes = endpointInfo2.getService().getDescription().getExtensors(TypeMappingType.class);
    if (corbaTypes != null) {
        typeMap = CorbaUtils.createCorbaTypeMap(corbaTypes);
    }
    ExceptionList exList = conduit.getExceptionList(conduit.getOperationExceptions(opType, typeMap), message, opType);
    assertNotNull("ExceptionList is not null", exList != null);
    assertNotNull("TypeCode is not null", exList.item(0) != null);
    assertEquals("ID should be equal", exList.item(0).id(), "IDL:BadRecord:1.0");
    assertEquals("ID should be equal", exList.item(0).name(), "BadRecord");
    assertEquals("ID should be equal", exList.item(0).member_count(), 2);
    assertEquals("ID should be equal", exList.item(0).member_name(0), "reason");
    assertNotNull("Member type is not null", exList.item(0).member_type(0) != null);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Message(org.apache.cxf.message.Message) QName(javax.xml.namespace.QName) ExceptionList(org.omg.CORBA.ExceptionList) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Example 2 with TypeMappingType

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

the class CorbaHandlerUtilsTest method setUp.

@Before
public void setUp() throws Exception {
    bus = BusFactory.getDefaultBus();
    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
    factory = bfm.getBindingFactory("http://cxf.apache.org/bindings/corba");
    bfm.registerBindingFactory(CorbaConstants.NU_WSDL_CORBA, factory);
    java.util.Properties props = System.getProperties();
    props.put("yoko.orb.id", "CXF-CORBA-Server-Binding");
    orb = ORB.init(new String[0], props);
    CorbaDestination destination = getDestination();
    service = destination.getBindingInfo().getService();
    List<TypeMappingType> corbaTypes = service.getDescription().getExtensors(TypeMappingType.class);
    typeMap = CorbaUtils.createCorbaTypeMap(corbaTypes);
}
Also used : CorbaDestination(org.apache.cxf.binding.corba.CorbaDestination) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) Before(org.junit.Before)

Example 3 with TypeMappingType

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

the class ScopedNameVisitor method populateAliasSchemaType.

protected static void populateAliasSchemaType(CorbaType corbaType, WSDLASTVisitor wsdlVisitor, VisitorTypeHolder holder) {
    XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
    TypeMappingType typeMap = wsdlVisitor.getTypeMap();
    holder.setCorbaType(corbaType);
    Alias alias = (Alias) corbaType;
    // loop through alias base types, till you get a non-alias corba type
    CorbaType type = findCorbaType(typeMap, alias.getBasetype());
    while ((type != null) && (type instanceof Alias)) {
        alias = (Alias) type;
        type = findCorbaType(typeMap, alias.getBasetype());
    }
    QName tname;
    if (type == null) {
        // it must be a primitive type
        tname = xmlSchemaPrimitiveMap.get(alias.getBasetype());
    } else {
        tname = type.getType();
    }
    XmlSchemaType stype = schemas.getTypeByQName(tname);
    if (stype == null) {
        XmlSchema xmlSchema = wsdlVisitor.getManager().getXmlSchema(tname.getNamespaceURI());
        if (xmlSchema != null) {
            stype = xmlSchema.getTypeByName(tname);
        } else {
            stype = wsdlVisitor.getSchema().getTypeByName(tname);
        }
    }
    holder.setSchemaType(stype);
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchema(org.apache.ws.commons.schema.XmlSchema) Alias(org.apache.cxf.binding.corba.wsdl.Alias) QName(javax.xml.namespace.QName) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection)

Example 4 with TypeMappingType

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

the class ScopedNameVisitor method findScopeSchemaType.

// Searches this scope for the schema type.
private static boolean findScopeSchemaType(Scope scopedName, XmlSchema schemaRef, WSDLASTVisitor wsdlVisitor, VisitorTypeHolder holder) {
    XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
    TypeMappingType typeMap = wsdlVisitor.getTypeMap();
    ModuleToNSMapper mapper = wsdlVisitor.getModuleToNSMapper();
    WSDLSchemaManager manager = wsdlVisitor.getManager();
    boolean result = findNonSchemaType(scopedName.toString(), wsdlVisitor, holder);
    if (!result) {
        XmlSchema xmlSchema = schemaRef;
        String tns = wsdlVisitor.getModuleToNSMapper().map(scopedName.getParent());
        if (tns != null) {
            xmlSchema = wsdlVisitor.getManager().getXmlSchema(tns);
        }
        XmlSchemaType stype = null;
        if (xmlSchema != null) {
            // Exceptions are treated as a special case as for the
            // doc/literal style
            // in the schema we will have an element and a complextype
            // so the name
            // and the typename will be different.
            final String scopedNameString;
            if (mapper.isDefaultMapping()) {
                scopedNameString = scopedName.toString();
            } else {
                scopedNameString = scopedName.tail();
            }
            final QName qname;
            if (exceptionMode) {
                qname = new QName(xmlSchema.getTargetNamespace(), scopedNameString + "Type");
            } else {
                qname = new QName(xmlSchema.getTargetNamespace(), scopedNameString);
            }
            stype = xmlSchema.getTypeByName(qname);
            if (stype == null) {
                stype = schemas.getTypeByQName(qname);
            }
        }
        if (stype != null) {
            result = true;
        }
        if (result && holder != null) {
            holder.setSchemaType(stype);
            holder.setCorbaType(getCorbaSchemaType(xmlSchema, typeMap, stype, scopedName));
            // add a xmlschema import
            if (!schemaRef.getTargetNamespace().equals(xmlSchema.getTargetNamespace())) {
                String importFile = wsdlVisitor.getOutputDir() + System.getProperty("file.separator") + scopedName.getParent().toString("_");
                manager.addXmlSchemaImport(schemaRef, xmlSchema, importFile);
            }
        }
    }
    return result;
}
Also used : XmlSchema(org.apache.ws.commons.schema.XmlSchema) QName(javax.xml.namespace.QName) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection)

Example 5 with TypeMappingType

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

the class ScopedNameVisitor method findNonSchemaType.

protected static boolean findNonSchemaType(String name, WSDLASTVisitor wsdlVisitor, VisitorTypeHolder holder) {
    boolean result = false;
    TypeMappingType typeMap = wsdlVisitor.getTypeMap();
    XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
    QName qname = new QName(typeMap.getTargetNamespace(), name);
    CorbaType corbaType = findCorbaType(typeMap, qname);
    if (corbaType != null) {
        if (corbaType instanceof Alias) {
            result = true;
            if (holder != null) {
                populateAliasSchemaType(corbaType, wsdlVisitor, holder);
            }
        } else if (((corbaType instanceof Sequence) || (corbaType instanceof Anonsequence)) && ((corbaType.getType().equals(Constants.XSD_BASE64)))) {
            // special case of sequence of octets
            result = true;
            if (holder != null) {
                holder.setCorbaType(corbaType);
                holder.setSchemaType(schemas.getTypeByQName(corbaType.getType()));
            }
        }
    }
    return result;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) Alias(org.apache.cxf.binding.corba.wsdl.Alias) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence)

Aggregations

TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)15 Definition (javax.wsdl.Definition)8 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)8 Test (org.junit.Test)8 QName (javax.xml.namespace.QName)7 File (java.io.File)6 WSDLToIDLAction (org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction)6 Document (org.w3c.dom.Document)5 Element (org.w3c.dom.Element)5 XmlSchemaCollection (org.apache.ws.commons.schema.XmlSchemaCollection)4 Struct (org.apache.cxf.binding.corba.wsdl.Struct)3 Union (org.apache.cxf.binding.corba.wsdl.Union)3 XmlSchema (org.apache.ws.commons.schema.XmlSchema)3 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)3 HashMap (java.util.HashMap)2 Binding (javax.wsdl.Binding)2 BindingOperation (javax.wsdl.BindingOperation)2 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)2 CorbaTypeMap (org.apache.cxf.binding.corba.CorbaTypeMap)2 Alias (org.apache.cxf.binding.corba.wsdl.Alias)2