Search in sources :

Example 21 with XmlSchemaType

use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.

the class WSDLParameter method processOutputParams.

private void processOutputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, SchemaCollection xmlSchemaList, List<ParamType> inputs, List<ParamType> outputs) throws Exception {
    Output output = operation.getOutput();
    if (output != null) {
        Message msg = output.getMessage();
        List<Part> parts = CastUtils.cast(msg.getOrderedParts(null));
        for (Part part : parts) {
            XmlSchemaType schemaType = null;
            // check if in input list
            String mode = "out";
            ParamType paramtype = null;
            boolean isObjectRef = isObjectReference(xmlSchemaList, part.getElementName());
            for (int x = 0; x < inputs.size(); x++) {
                paramtype = null;
                ParamType d2 = inputs.get(x);
                if (part.getElementName() != null && !isObjectRef) {
                    XmlSchemaElement el = getElement(part, xmlSchemaList);
                    if (el != null) {
                        if (el.getSchemaType() != null) {
                            schemaType = el.getSchemaType();
                        }
                        QName typeName = el.getSchemaTypeName();
                        if (typeName == null) {
                            typeName = el.getQName();
                        }
                        QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, el.isNillable());
                        if ((d2.getName().equals(part.getName())) && (d2.getIdltype().equals(idltype))) {
                            inputs.remove(x);
                            paramtype = createParam(wsdlToCorbaBinding, "inout", part.getName(), idltype);
                            inputs.add(paramtype);
                        }
                    }
                } else {
                    schemaType = getType(part, xmlSchemaList);
                    QName typeName = part.getTypeName();
                    if (isObjectRef) {
                        typeName = part.getElementName();
                    }
                    QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, false);
                    if ((d2.getName().equals(part.getName())) && (d2.getIdltype().equals(idltype))) {
                        inputs.remove(x);
                        paramtype = createParam(wsdlToCorbaBinding, "inout", part.getName(), idltype);
                        inputs.add(paramtype);
                    }
                }
            }
            if (paramtype == null) {
                if (part.getElementName() != null && !isObjectRef) {
                    XmlSchemaElement el = getElement(part, xmlSchemaList);
                    QName typeName = el.getSchemaTypeName();
                    if (typeName == null) {
                        typeName = el.getQName();
                    }
                    QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, el.isNillable());
                    paramtype = createParam(wsdlToCorbaBinding, mode, part.getName(), idltype);
                } else {
                    QName typeName = part.getTypeName();
                    if (isObjectRef) {
                        typeName = part.getElementName();
                    }
                    QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, false);
                    paramtype = createParam(wsdlToCorbaBinding, mode, part.getName(), idltype);
                }
                if (paramtype != null) {
                    outputs.add(paramtype);
                }
            }
        }
    }
}
Also used : Message(javax.wsdl.Message) Part(javax.wsdl.Part) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) Output(javax.wsdl.Output) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType)

Example 22 with XmlSchemaType

use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.

the class WSDLToCorbaHelper method processSimpleRestrictionType.

private CorbaType processSimpleRestrictionType(XmlSchemaSimpleType stype, QName name, QName schematypeName, boolean anonymous) throws Exception {
    CorbaType corbaTypeImpl;
    // checks if enumeration
    XmlSchemaSimpleTypeRestriction restrictionType = (XmlSchemaSimpleTypeRestriction) stype.getContent();
    QName baseName = checkPrefix(restrictionType.getBaseTypeName());
    String maxLength = null;
    String length = null;
    for (XmlSchemaFacet val : restrictionType.getFacets()) {
        if (val instanceof XmlSchemaMaxLengthFacet) {
            maxLength = val.getValue().toString();
        }
        if (val instanceof XmlSchemaLengthFacet) {
            length = val.getValue().toString();
        }
    }
    if (isEnumeration(restrictionType)) {
        corbaTypeImpl = createCorbaEnum(restrictionType, name, schematypeName);
    } else {
        if (restrictionType.getBaseType() != null) {
            corbaTypeImpl = convertSchemaToCorbaType(restrictionType.getBaseType(), schematypeName, stype, null, false);
        } else {
            corbaTypeImpl = processPrimitiveType(baseName);
            if (corbaTypeImpl == null) {
                XmlSchemaType schematype = findSchemaType(baseName);
                corbaTypeImpl = convertSchemaToCorbaType(schematype, schematypeName, schematype, null, false);
            }
        }
        if (corbaTypeImpl != null) {
            if (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_STRING) || (baseName.equals(W3CConstants.NT_SCHEMA_STRING))) {
                corbaTypeImpl = WSDLTypes.processStringType(corbaTypeImpl, name, maxLength, length);
            } else if (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_DECIMAL) || (baseName.equals(W3CConstants.NT_SCHEMA_DECIMAL))) {
                corbaTypeImpl = WSDLTypes.processDecimalType(restrictionType, name, corbaTypeImpl, anonymous);
            } else if ((corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_BASE64)) || (baseName.equals(W3CConstants.NT_SCHEMA_BASE64)) || (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_HBIN))) {
                corbaTypeImpl = WSDLTypes.processBase64Type(corbaTypeImpl, name, maxLength, length);
            }
        }
    }
    return corbaTypeImpl;
}
Also used : XmlSchemaFacet(org.apache.ws.commons.schema.XmlSchemaFacet) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) XmlSchemaSimpleTypeRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction) XmlSchemaLengthFacet(org.apache.ws.commons.schema.XmlSchemaLengthFacet) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaMaxLengthFacet(org.apache.ws.commons.schema.XmlSchemaMaxLengthFacet)

Example 23 with XmlSchemaType

use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.

the class WSDLToCorbaHelper method getSchemaType.

public XmlSchemaType getSchemaType(QName name) throws Exception {
    XmlSchemaType type = null;
    for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
        String nspace = name.getNamespaceURI();
        if (nspace == null) {
            nspace = xmlSchema.getTargetNamespace();
        }
        // QName tname = createQName(nspace, name.getLocalPart(), "xsd");
        QName tname = createQName(nspace, name.getLocalPart(), "");
        type = findSchemaType(tname);
        if (type != null) {
            break;
        }
    }
    return type;
}
Also used : XmlSchema(org.apache.ws.commons.schema.XmlSchema) QName(javax.xml.namespace.QName) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 24 with XmlSchemaType

use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.

the class WSDLToCorbaHelper method processLiteralArray.

private CorbaType processLiteralArray(XmlSchemaComplexType complex, QName defaultName, boolean anonymous) throws Exception {
    // NEED TO DO
    QName name;
    QName typeName = null;
    QName schematypeName = checkPrefix(complex.getQName());
    if (schematypeName == null) {
        schematypeName = defaultName;
        name = createQNameCorbaNamespace(defaultName.getLocalPart() + "Type");
        schematypeName = checkPrefix(schematypeName);
        name = checkPrefix(name);
    } else {
        name = createQNameCorbaNamespace(schematypeName.getLocalPart());
        name = checkPrefix(name);
    }
    CorbaType arrayType = null;
    XmlSchemaElement arrayEl = null;
    QName elName = null;
    if (complex.getParticle() instanceof XmlSchemaSequence) {
        XmlSchemaSequence seq = (XmlSchemaSequence) complex.getParticle();
        Iterator<XmlSchemaSequenceMember> iterator = seq.getItems().iterator();
        Iterator<XmlSchemaSequenceMember> iter = seq.getItems().iterator();
        while (iterator.hasNext()) {
            if (iter.next() instanceof XmlSchemaElement) {
                arrayEl = (XmlSchemaElement) iterator.next();
                elName = arrayEl.getQName();
                XmlSchemaType atype = arrayEl.getSchemaType();
                if (elName == null) {
                    elName = arrayEl.getRef().getTargetQName();
                    /*
                         * TODO: why are we looking up an element name with findSchemaType?
                         */
                    atype = findSchemaType(elName);
                }
                String uri = defaultName.getNamespaceURI();
                if (complex.getQName() != null) {
                    uri = complex.getQName().getNamespaceURI();
                }
                if (elName.getNamespaceURI().isEmpty()) {
                    elName = new QName(uri, elName.getLocalPart());
                }
                QName arrayTypeName = elName;
                if (anonymous) {
                    arrayTypeName = new QName(elName.getNamespaceURI(), defaultName.getLocalPart() + "." + elName.getLocalPart());
                }
                arrayType = convertSchemaToCorbaType(atype, arrayTypeName, atype, null, true);
                boolean isQualified = getElementQualification(arrayEl, uri);
                if (isQualified) {
                    arrayType.setQualified(isQualified);
                } else {
                    elName = new QName("", elName.getLocalPart());
                }
                typeName = arrayType.getQName();
            }
        }
    }
    Long maxOccurs = null;
    Long minOccurs = null;
    if (arrayEl != null) {
        if (arrayEl.isNillable()) {
            QName nilunionname = createQNameTargetNamespace(arrayType.getQName().getLocalPart() + "_nil");
            boolean isQualified = arrayType.isSetQualified() && arrayType.isQualified();
            arrayType = createNillableUnion(nilunionname, elName, arrayType.getQName(), isQualified);
            typeName = createQNameCorbaNamespace(arrayType.getQName().getLocalPart());
            if (arrayType != null && !isDuplicate(arrayType)) {
                typeMappingType.getStructOrExceptionOrUnion().add(arrayType);
            }
        }
        maxOccurs = arrayEl.getMaxOccurs();
        minOccurs = arrayEl.getMinOccurs();
    }
    return createArray(name, schematypeName, checkPrefix(typeName), elName, maxOccurs, minOccurs, anonymous);
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaSequenceMember(org.apache.ws.commons.schema.XmlSchemaSequenceMember) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 25 with XmlSchemaType

use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.

the class WSDLToCorbaHelper method processLocalElement.

private CorbaType processLocalElement(QName containingTypeName, XmlSchemaElement element, String uri) throws Exception {
    CorbaType membertype = new CorbaType();
    XmlSchemaType schemaType = element.getSchemaType();
    QName schemaName = element.getQName();
    if (schemaType == null) {
        if (element.getRef().getTarget() != null) {
            schemaType = findSchemaType(element.getRef().getTarget().getSchemaTypeName());
            schemaName = element.getRef().getTargetQName();
        } else {
            schemaType = findSchemaType(element.getSchemaTypeName());
        }
    }
    if (schemaName.getNamespaceURI().isEmpty()) {
        schemaName = new QName(uri, schemaName.getLocalPart());
    }
    QName elemName = schemaName;
    boolean elementQualified = getElementQualification(element, uri);
    if (!elementQualified) {
        elemName = new QName("", elemName.getLocalPart());
    }
    QName memName = null;
    if (element.isNillable()) {
        CorbaType elemtype = convertSchemaToCorbaType(schemaType, elemName, schemaType, null, true);
        QName name = createQNameTargetNamespace(elemtype.getQName().getLocalPart() + "_nil");
        QName elName = checkPrefix(elemName);
        if (elName == null) {
            elName = createQNameTargetNamespace(elemName.getLocalPart());
        }
        CorbaType memtype = createNillableUnion(elName, name, elemtype.getQName(), elementQualified);
        memName = createQNameCorbaNamespace(memtype.getQName().getLocalPart());
        if (!isDuplicate(memtype)) {
            typeMappingType.getStructOrExceptionOrUnion().add(memtype);
        }
        membertype.setQName(memName);
        membertype.setName(memtype.getName());
        membertype.setType(memtype.getType());
    } else if (schemaType != null) {
        XmlSchemaType st = schemaType;
        boolean anonymous = WSDLTypes.isAnonymous(st.getName());
        final QName typeName;
        if (anonymous) {
            typeName = new QName(elemName.getNamespaceURI(), containingTypeName.getLocalPart() + "." + elemName.getLocalPart());
        } else {
            typeName = st.getQName();
        }
        membertype = convertSchemaToCorbaType(st, typeName, st, null, anonymous);
    } else if (element.getSchemaTypeName() != null) {
        QName name = checkPrefix(element.getSchemaTypeName());
        membertype = getLocalType(name);
    }
    if (membertype == null) {
        return null;
    }
    if (element.getMaxOccurs() != 1 || element.getMinOccurs() != 1) {
        QName name = createQNameCorbaNamespace(getModulePrefix(membertype) + elemName.getLocalPart() + "Array");
        final CorbaType arraytype;
        if (memName != null) {
            arraytype = createArray(name, /*schemaName*/
            name, memName, elemName, element.getMaxOccurs(), element.getMinOccurs(), false);
        } else {
            arraytype = createArray(name, /*schemaName*/
            name, membertype.getQName(), elemName, element.getMaxOccurs(), element.getMinOccurs(), false);
        }
        if (arraytype != null) {
            if (arraytype instanceof Abstractsequence) {
                ((Abstractsequence) arraytype).setWrapped(false);
            }
            if (arraytype instanceof Abstractanonsequence) {
                ((Abstractanonsequence) arraytype).setWrapped(false);
            }
            if (!isDuplicate(arraytype)) {
                typeMappingType.getStructOrExceptionOrUnion().add(arraytype);
            }
            // the local element with maxOccurs != 1 or minOccurs != 1 becomes the just created array
            membertype = arraytype;
        }
    }
    membertype.setQualified(elementQualified);
    return membertype;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) Abstractsequence(org.apache.cxf.binding.corba.wsdl.Abstractsequence) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) Abstractanonsequence(org.apache.cxf.binding.corba.wsdl.Abstractanonsequence)

Aggregations

XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)81 QName (javax.xml.namespace.QName)47 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)37 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)23 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)23 XmlSchema (org.apache.ws.commons.schema.XmlSchema)21 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)16 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)12 AST (antlr.collections.AST)8 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)8 XmlSchemaComplexContentExtension (org.apache.ws.commons.schema.XmlSchemaComplexContentExtension)7 XmlSchemaObjectCollection (org.apache.ws.commons.schema.XmlSchemaObjectCollection)6 SchemaInfo (org.apache.cxf.service.model.SchemaInfo)5 XmlSchemaGroupBase (org.apache.ws.commons.schema.XmlSchemaGroupBase)5 XmlSchemaParticle (org.apache.ws.commons.schema.XmlSchemaParticle)5 ArrayList (java.util.ArrayList)4 CorbaTypeImpl (org.apache.cxf.binding.corba.wsdl.CorbaTypeImpl)4 Message (org.apache.cxf.common.i18n.Message)4 ParticleInfo (org.apache.cxf.javascript.ParticleInfo)4 XmlSchemaCollection (org.apache.ws.commons.schema.XmlSchemaCollection)4