Search in sources :

Example 61 with XmlSchemaElement

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

the class JavascriptUtils method getObjectParticle.

/**
 * If the object is an element or an any, return the particle. If it's not a particle, or it's a group,
 * throw. We're not ready for groups yet.
 * @param object
 */
public static XmlSchemaParticle getObjectParticle(XmlSchemaObject object, QName contextName, XmlSchema currentSchema) {
    if (!(object instanceof XmlSchemaParticle)) {
        throw unsupportedConstruct("NON_PARTICLE_CHILD", object.getClass().getSimpleName(), contextName, object);
    }
    if (object instanceof XmlSchemaGroupRef) {
        QName groupName = ((XmlSchemaGroupRef) object).getRefName();
        XmlSchemaGroup group = currentSchema.getGroupByName(groupName);
        if (group == null) {
            throw unsupportedConstruct("MISSING_GROUP", groupName.toString(), contextName, null);
        }
        XmlSchemaParticle groupParticle = group.getParticle();
        if (!(groupParticle instanceof XmlSchemaSequence)) {
            throw unsupportedConstruct("GROUP_REF_UNSUPPORTED_TYPE", groupParticle.getClass().getSimpleName(), contextName, groupParticle);
        }
        return groupParticle;
    }
    if (!(object instanceof XmlSchemaElement) && !(object instanceof XmlSchemaAny) && !(object instanceof XmlSchemaChoice) && !(object instanceof XmlSchemaSequence)) {
        throw unsupportedConstruct("GROUP_CHILD", object.getClass().getSimpleName(), contextName, object);
    }
    return (XmlSchemaParticle) object;
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaGroup(org.apache.ws.commons.schema.XmlSchemaGroup) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaChoice(org.apache.ws.commons.schema.XmlSchemaChoice) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) XmlSchemaGroupRef(org.apache.ws.commons.schema.XmlSchemaGroupRef) XmlSchemaAny(org.apache.ws.commons.schema.XmlSchemaAny)

Example 62 with XmlSchemaElement

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

the class WSDLServiceBuilder method buildMessage.

private void buildMessage(AbstractMessageContainer minfo, Message msg) {
    SchemaCollection schemas = minfo.getOperation().getInterface().getService().getXmlSchemaCollection();
    List<?> orderedParam = msg.getOrderedParts(null);
    for (Part part : cast(orderedParam, Part.class)) {
        MessagePartInfo pi = minfo.addMessagePart(new QName(minfo.getName().getNamespaceURI(), part.getName()));
        if (part.getTypeName() != null) {
            pi.setTypeQName(part.getTypeName());
            pi.setElement(false);
            pi.setXmlSchema(schemas.getTypeByQName(part.getTypeName()));
        } else if (part.getElementName() != null) {
            pi.setElementQName(part.getElementName());
            XmlSchemaElement schemaElement = schemas.getElementByQName(part.getElementName());
            if (null == schemaElement) {
                org.apache.cxf.common.i18n.Message errorMessage = new org.apache.cxf.common.i18n.Message("WSDL4J_BAD_ELEMENT_PART", LOG, part.getName(), part.getElementName());
                throw new WSDLRuntimeException(errorMessage);
            }
            pi.setElement(true);
            pi.setXmlSchema(schemaElement);
        } else {
            org.apache.cxf.common.i18n.Message errorMessage = new org.apache.cxf.common.i18n.Message("PART_NO_NAME_NO_TYPE", LOG, part.getName());
            throw new WSDLRuntimeException(errorMessage);
        }
    }
}
Also used : Message(javax.wsdl.Message) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) Part(javax.wsdl.Part) SchemaCollection(org.apache.cxf.common.xmlschema.SchemaCollection)

Example 63 with XmlSchemaElement

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

the class WSDLServiceBuilder method buildMessageParts.

private static boolean buildMessageParts(XmlSchemaSequence seq, String namespaceURI, MessageInfo wrapper, boolean allowRefs) {
    List<XmlSchemaSequenceMember> items = seq.getItems();
    boolean ret = true;
    for (XmlSchemaSequenceMember seqItem : items) {
        if (!(seqItem instanceof XmlSchemaElement)) {
            return false;
        }
        XmlSchemaElement el = (XmlSchemaElement) seqItem;
        if (el.getSchemaTypeName() != null) {
            MessagePartInfo mpi = wrapper.addMessagePart(new QName(namespaceURI, el.getName()));
            mpi.setTypeQName(el.getSchemaTypeName());
            mpi.setElement(true);
            mpi.setElementQName(el.getWireName());
            mpi.setConcreteName(el.getWireName());
            mpi.setXmlSchema(el);
        } else if (el.getRef().getTargetQName() != null) {
            MessagePartInfo mpi = wrapper.addMessagePart(el.getRef().getTargetQName());
            mpi.setTypeQName(el.getRef().getTargetQName());
            mpi.setElementQName(el.getRef().getTargetQName());
            mpi.setElement(true);
            mpi.setXmlSchema(el);
            mpi.setProperty("isRefElement", true);
            // element reference is not permitted for wrapper element
            if (!allowRefs) {
                ret = false;
            }
        } else {
            // anonymous type
            MessagePartInfo mpi = wrapper.addMessagePart(new QName(namespaceURI, el.getName()));
            mpi.setElementQName(mpi.getName());
            mpi.setConcreteName(el.getWireName());
            mpi.setElement(true);
            mpi.setXmlSchema(el);
        }
    }
    return ret;
}
Also used : XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) XmlSchemaSequenceMember(org.apache.ws.commons.schema.XmlSchemaSequenceMember) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Example 64 with XmlSchemaElement

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

the class ParameterProcessor method processReturn.

private void processReturn(JavaMethod method, MessagePartInfo part) {
    String name = part == null ? "return" : part.getName().getLocalPart();
    String type = part == null ? "void" : ProcessorUtil.resolvePartType(part, context);
    String namespace = part == null ? null : ProcessorUtil.resolvePartNamespace(part);
    JavaReturn returnType = new JavaReturn(name, type, namespace);
    if (part != null) {
        returnType.setDefaultValueWriter(ProcessorUtil.getDefaultValueWriter(part, context));
    }
    returnType.setQName(ProcessorUtil.getElementName(part));
    returnType.setStyle(JavaType.Style.OUT);
    if (namespace != null && type != null && !"void".equals(type)) {
        returnType.setClassName(ProcessorUtil.getFullClzName(part, context, false));
    }
    if (part != null && part.getXmlSchema() instanceof XmlSchemaSimpleType) {
        processXmlSchemaSimpleType((XmlSchemaSimpleType) part.getXmlSchema(), method, part);
    } else if (part != null && part.getXmlSchema() instanceof XmlSchemaElement) {
        XmlSchemaElement element = (XmlSchemaElement) part.getXmlSchema();
        if (element.getSchemaType() instanceof XmlSchemaSimpleType) {
            processXmlSchemaSimpleType((XmlSchemaSimpleType) element.getSchemaType(), method, part);
        }
    }
    method.setReturn(returnType);
}
Also used : JavaReturn(org.apache.cxf.tools.common.model.JavaReturn) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement)

Example 65 with XmlSchemaElement

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

the class OperationVisitor method addElement.

private XmlSchemaElement addElement(XmlSchemaSequence schemaSequence, XmlSchemaType schemaType, Scope fqName, String name) {
    XmlSchemaElement element = new XmlSchemaElement(schema, false);
    element.setName(name);
    if (schemaType != null) {
        element.setSchemaTypeName(schemaType.getQName());
        if (schemaType.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
            element.setNillable(true);
        }
    } else {
        wsdlVisitor.getDeferredActions().add(fqName, new OperationDeferredAction(element));
    }
    schemaSequence.getItems().add(element);
    return element;
}
Also used : XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement)

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