Search in sources :

Example 76 with XmlSchemaElement

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

the class WSDLToCorbaBinding method addCorbaElements.

private void addCorbaElements(XmlSchema xmlSchemaTypes) throws Exception {
    Map<QName, XmlSchemaElement> elements = xmlSchemaTypes.getElements();
    for (XmlSchemaElement el : elements.values()) {
        QName elName = el.getQName();
        XmlSchemaType schemaType = el.getSchemaType();
        if (elName == null) {
            elName = el.getRef().getTargetQName();
            schemaType = helper.getSchemaType(elName);
        }
        boolean anonymous;
        if (schemaType == null) {
            anonymous = true;
        } else {
            anonymous = WSDLTypes.isAnonymous(schemaType.getName());
        }
        if (schemaType != null) {
            XmlSchemaAnnotation annotation = null;
            if (el.getAnnotation() != null) {
                annotation = el.getAnnotation();
            }
            // this situation won't be handled. REVISIT.
            if (annotation != null) {
                XmlSchemaAppInfo appInfo = null;
                for (XmlSchemaAnnotationItem ann : annotation.getItems()) {
                    if (ann instanceof XmlSchemaAppInfo) {
                        appInfo = (XmlSchemaAppInfo) ann;
                        break;
                    }
                }
                if (appInfo != null) {
                    NodeList nlist = appInfo.getMarkup();
                    Node node = nlist.item(0);
                    String info = node.getNodeValue();
                    info = info.trim();
                    String annotationBindingName = "";
                    if ("corba:binding=".equals(info.substring(0, 14))) {
                        annotationBindingName = info.substring(14);
                    }
                    if (bindingName.equals(annotationBindingName)) {
                        annotation = null;
                    }
                }
            }
            CorbaType corbaTypeImpl = helper.convertSchemaToCorbaType(schemaType, elName, schemaType, annotation, anonymous);
            if (el.isNillable()) {
                QName uname = helper.createQNameCorbaNamespace(corbaTypeImpl.getQName().getLocalPart() + "_nil");
                boolean isQualified = corbaTypeImpl.isSetQualified() && corbaTypeImpl.isQualified();
                corbaTypeImpl = helper.createNillableUnion(uname, helper.checkPrefix(elName), helper.checkPrefix(corbaTypeImpl.getQName()), isQualified);
            }
            if (corbaTypeImpl != null && !helper.isDuplicate(corbaTypeImpl)) {
                typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
            }
        }
    }
}
Also used : XmlSchemaAnnotationItem(org.apache.ws.commons.schema.XmlSchemaAnnotationItem) XmlSchemaAnnotation(org.apache.ws.commons.schema.XmlSchemaAnnotation) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaAppInfo(org.apache.ws.commons.schema.XmlSchemaAppInfo)

Example 77 with XmlSchemaElement

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

the class WSDLTypes method isOMGUnion.

public static boolean isOMGUnion(XmlSchemaComplexType type) {
    boolean isUnion = false;
    if (type.getParticle() instanceof XmlSchemaSequence && type.getAttributes().isEmpty()) {
        XmlSchemaSequence stype = (XmlSchemaSequence) type.getParticle();
        if (stype.getItems().size() == 2) {
            XmlSchemaParticle st1 = (XmlSchemaParticle) stype.getItems().get(0);
            XmlSchemaParticle st2 = (XmlSchemaParticle) stype.getItems().get(1);
            XmlSchemaElement discEl = null;
            if (st1 instanceof XmlSchemaChoice && st2 instanceof XmlSchemaElement) {
                isUnion = true;
                discEl = (XmlSchemaElement) st2;
            } else if (st2 instanceof XmlSchemaChoice && st1 instanceof XmlSchemaElement) {
                isUnion = true;
                discEl = (XmlSchemaElement) st1;
            }
            if (isUnion && !"discriminator".equals(discEl.getQName().getLocalPart())) {
                isUnion = false;
            }
        }
    }
    return isUnion;
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaChoice(org.apache.ws.commons.schema.XmlSchemaChoice) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle)

Example 78 with XmlSchemaElement

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

the class WSDLParameter method processWrappedOutputParams.

private void processWrappedOutputParams(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();
        Part part = (Part) msg.getOrderedParts(null).iterator().next();
        XmlSchemaComplexType schemaType = null;
        XmlSchemaElement el = getElement(part, xmlSchemaList);
        if (el == null) {
            return;
        }
        if (el.getSchemaType() != null) {
            schemaType = (XmlSchemaComplexType) el.getSchemaType();
        }
        XmlSchemaSequence seq = (XmlSchemaSequence) schemaType.getParticle();
        if (seq != null) {
            for (XmlSchemaSequenceMember seqMember : seq.getItems()) {
                if (seqMember instanceof XmlSchemaElement) {
                    el = (XmlSchemaElement) seqMember;
                    processWrappedOutputParam(wsdlToCorbaBinding, el, inputs, outputs);
                }
            }
        }
    }
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) Message(javax.wsdl.Message) Part(javax.wsdl.Part) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Output(javax.wsdl.Output) XmlSchemaSequenceMember(org.apache.ws.commons.schema.XmlSchemaSequenceMember) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType)

Example 79 with XmlSchemaElement

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

the class WSDLParameter method processInputParams.

private void processInputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, SchemaCollection xmlSchemaList, List<ParamType> inputs) throws Exception {
    Input input = operation.getInput();
    if (input != null) {
        Message msg = input.getMessage();
        List<Part> parts = CastUtils.cast(msg.getOrderedParts(null));
        for (Part part : parts) {
            XmlSchemaType schemaType = null;
            boolean isObjectRef = isObjectReference(xmlSchemaList, part.getElementName());
            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());
                    ParamType paramtype = createParam(wsdlToCorbaBinding, "in", part.getName(), idltype);
                    if (paramtype != null) {
                        inputs.add(paramtype);
                    }
                }
            } else if (part.getTypeName() != null) {
                schemaType = getType(part, xmlSchemaList);
                QName typeName = part.getTypeName();
                if (isObjectRef) {
                    typeName = part.getElementName();
                }
                QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, false);
                ParamType paramtype = createParam(wsdlToCorbaBinding, "in", part.getName(), idltype);
                if (paramtype != null) {
                    inputs.add(paramtype);
                }
            }
        }
    }
}
Also used : Input(javax.wsdl.Input) Message(javax.wsdl.Message) Part(javax.wsdl.Part) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType)

Example 80 with XmlSchemaElement

use of org.apache.ws.commons.schema.XmlSchemaElement 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)

Aggregations

XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)164 QName (javax.xml.namespace.QName)100 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)59 XmlSchema (org.apache.ws.commons.schema.XmlSchema)54 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)51 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)42 Test (org.junit.Test)42 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)39 FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)32 Message (org.apache.cxf.common.i18n.Message)15 XmlSchemaParticle (org.apache.ws.commons.schema.XmlSchemaParticle)15 XmlSchemaSequenceMember (org.apache.ws.commons.schema.XmlSchemaSequenceMember)14 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)13 ArrayList (java.util.ArrayList)12 JAXBBeanInfo (org.apache.cxf.common.jaxb.JAXBBeanInfo)12 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)12 Method (java.lang.reflect.Method)11 SchemaInfo (org.apache.cxf.service.model.SchemaInfo)11 XmlSchemaAttribute (org.apache.ws.commons.schema.XmlSchemaAttribute)10 Iterator (java.util.Iterator)9