private void addGlobalElement(final XmlSchemaElement element) { // Nested anonymous type QName xmlType = element.getSchemaTypeName(); if (xmlType == null) { // Rule 1.b: Anonymous type inside an element ">E" xmlType = new QName(element.getQName().getNamespaceURI(), ">" + element.getQName().getLocalPart()); addType(xmlType, element.getSchemaType()); } // create the XmlElementInfo final XmlElementInfo elementInfo = createXmlElementInfo(element.getQName(), xmlType, element); xmlElements.put(element.getQName(), elementInfo); }
/** * By convention, an element that is named in its schema's TNS can have a 'name' but * no QName. This can get inconvenient for consumers who want to think about qualified names. * Unfortunately, XmlSchema elements, unlike types, don't store a reference to their containing * schema. * @param element * @param schema */ public static QName getElementQualifiedName(XmlSchemaElement element, XmlSchema schema) { if (element.getQName() != null) { return element.getQName(); } else if (element.getName() != null) { return new QName(schema.getTargetNamespace(), element.getName()); } else { return null; } }
private boolean getElementQualification(XmlSchemaElement element, String uri) { QName schemaName = element.getQName(); if (element.isRef()) { schemaName = element.getRef().getTargetQName(); } if (schemaName.getNamespaceURI().isEmpty()) { schemaName = new QName(uri, schemaName.getLocalPart()); } boolean qualified = false; if (element.getForm() == XmlSchemaForm.QUALIFIED) { qualified = true; } else { qualified = WSDLUtils.isElementFormQualified(xmlSchemaList, schemaName); } return qualified; }
private XmlSchemaElement generateWrapper(QName el, XmlSchemaSequence wrappingSequence) { XmlSchemaComplexType schemaComplexType = new XmlSchemaComplexType(schema, false); schemaComplexType.setParticle(wrappingSequence); XmlSchemaElement wrappingSchemaElement = new XmlSchemaElement(schema, true); wrappingSchemaElement.setName(el.getLocalPart()); wrappingSchemaElement.setSchemaType(schemaComplexType); return wrappingSchemaElement; }
protected XmlSchemaComplexType getComplexTypeForElement(XmlSchema xmlSchema, QName name) { for (XmlSchemaObject object : xmlSchema.getItems()) { if (object instanceof XmlSchemaElement && ((XmlSchemaElement) object).getQName().equals(name)) { XmlSchemaComplexType xmlSchemaComplexType = (XmlSchemaComplexType) ((XmlSchemaElement) object).getSchemaType(); if ((xmlSchemaComplexType == null) && (((XmlSchemaElement) object).getSchemaTypeName() != null)) { xmlSchemaComplexType = (XmlSchemaComplexType) xmlSchema.getTypeByName(((XmlSchemaElement) object).getSchemaTypeName()); } return xmlSchemaComplexType; } } return null; }
protected void createBareMessage(ServiceInfo serviceInfo, OperationInfo opInfo, boolean isOut) { MessageInfo message = isOut ? opInfo.getOutput() : opInfo.getInput(); Method method = (Method)opInfo.getProperty(METHOD); int paraNumber = 0; for (MessagePartInfo mpi : messageParts) { XmlSchema schema = null; if (qname.getLocalPart().startsWith("arg") || qname.getLocalPart().startsWith("return")) { qname = isOut ? new QName(qname.getNamespaceURI(), method.getName() + "Response") : new QName(qname XmlSchemaElement el = new XmlSchemaElement(schema, true); el.setName(qname.getLocalPart()); el.setNillable(true); if (null != oldEl && !oldEl.getQName().equals(qname)) { el.setSchemaTypeName(oldEl.getSchemaTypeName()); el.setSchemaType(oldEl.getSchemaType()); if (oldEl.getSchemaTypeName() != null) { addImport(schema, oldEl.getSchemaTypeName().getNamespaceURI()); el.setSchemaTypeName(mpi.getTypeQName()); } else { el.setSchemaType((XmlSchemaType)mpi.getXmlSchema());
protected void checkForElement(ServiceInfo serviceInfo, MessagePartInfo mpi) { SchemaInfo si = getOrCreateSchema(serviceInfo, mpi.getElementQName().getNamespaceURI(), getQualifyWrapperSchema()); XmlSchemaElement e = si.getSchema().getElementByName(mpi.getElementQName().getLocalPart()); if (e != null) { mpi.setXmlSchema(e); return; } XmlSchema schema = si.getSchema(); si.setElement(null); //cached element is now invalid XmlSchemaElement el = new XmlSchemaElement(schema, true); el.setName(mpi.getElementQName().getLocalPart()); el.setNillable(true); XmlSchemaType tp = (XmlSchemaType)mpi.getXmlSchema(); if (tp == null) { throw new ServiceConstructionException(new Message("INTRACTABLE_PART", LOG, mpi.getName(), mpi.getMessageInfo().getName())); } el.setSchemaTypeName(tp.getQName()); mpi.setXmlSchema(el); }
= new org.apache.cxf.common.i18n.Message("WRAPPED_RULE_1", LOG, opInfo.getName()); LOG.log(logLevel, message.toString()); return; outputPart = outputMessage.getMessagePartByIndex(0); if (outputPart != null) { if (!outputPart.isElement() if (inputEl.getSchemaType() instanceof XmlSchemaComplexType) { xsct = (XmlSchemaComplexType)inputEl.getSchemaType(); if (hasAttributes(xsct) || (inputEl.isNillable() && !relaxed) || !isWrappableSequence(xsct, inputEl.getQName().getNamespaceURI(), unwrappedInput, allowRefs)) { passedRule = false; unwrappedOutput = new MessageInfo(unwrapped, MessageInfo.Type.OUTPUT, outputMessage.getName()); if (outputEl != null && outputEl.getSchemaType() instanceof XmlSchemaComplexType) { xsct = (XmlSchemaComplexType)outputEl.getSchemaType(); if (xsct.isAbstract()) { passedRule = false; || (outputEl.isNillable() && !relaxed) || !isWrappableSequence(xsct, outputEl.getQName().getNamespaceURI(), unwrappedOutput, allowRefs)) { passedRule = false;
XmlSchemaElement xmlSchemaElement = axisMessage.getSchemaElement(); if(xmlSchemaElement != null){ XmlSchemaType schemaType = xmlSchemaElement.getSchemaType(); if (schemaType instanceof XmlSchemaComplexType) { XmlSchemaComplexType complexType = ((XmlSchemaComplexType)schemaType); XmlSchemaParticle particle = complexType.getParticle(); if (particle instanceof XmlSchemaSequence || particle instanceof XmlSchemaAll) { XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase)particle; QName qName = innerElement.getQName(); if (qName == null && innerElement.getSchemaTypeName() .equals(org.apache.ws.commons.schema.constants.Constants.XSD_ANYTYPE)) { break; long minOccurs = innerElement.getMinOccurs(); boolean nillable = innerElement.isNillable(); String name = qName != null ? qName.getLocalPart() : innerElement.getName(); String type = innerElement.getSchemaTypeName().toString(); paramList.append(","+type +" " +name);
public static List<String> getOperationInputPartNames(OperationInfo operation) { List<String> names = new ArrayList<>(); List<MessagePartInfo> parts = operation.getInput().getMessageParts(); if (parts == null || parts.isEmpty()) { return names; } for (MessagePartInfo part : parts) { XmlSchemaAnnotated schema = part.getXmlSchema(); if (schema instanceof XmlSchemaElement && ((XmlSchemaElement)schema).getSchemaType() instanceof XmlSchemaComplexType) { XmlSchemaElement element = (XmlSchemaElement)schema; XmlSchemaComplexType cplxType = (XmlSchemaComplexType)element.getSchemaType(); XmlSchemaSequence seq = (XmlSchemaSequence)cplxType.getParticle(); if (seq == null || seq.getItems() == null) { return names; } for (int i = 0; i < seq.getItems().size(); i++) { XmlSchemaElement elChild = (XmlSchemaElement)seq.getItems().get(i); names.add(elChild.getName()); } } else { names.add(part.getConcreteName().getLocalPart()); } } return names; }
/** * Wrapper around XmlSchemaElement.setRefName that checks for inconsistency with * name and QName. * @param element * @param name */ public static void setElementRefName(XmlSchemaElement element, QName name) { if (name != null && ((element.getQName() != null && !element.getQName().equals(name)) || (element.getName() != null && !element.getName().equals(name.getLocalPart())))) { LOG.severe("Attempt to set the refName of an element with a name or QName"); throw new XmlSchemaInvalidOperation("Attempt to set the refName of an element " + "with a name or QName."); } element.getRef().setTargetQName(name); // cxf conventionally keeps something in the name slot. }
public WSDLPart(Part part, Class javaType) throws InvalidWSDLException { this.part = part; QName elementName = part.getElementName(); if (elementName != null) { element = WSDLOperationIntrospectorImpl.this.getElement(elementName); if (element == null) { throw new InvalidWSDLException("Element cannot be resolved: " + elementName.toString()); } } else { // Create an faked XSD element to host the metadata element = new XmlSchemaElement(); element.setName(part.getName()); element.setQName(new QName(null, part.getName())); QName typeName = part.getTypeName(); if (typeName != null) { XmlSchemaType type = WSDLOperationIntrospectorImpl.this.getType(typeName); if (type == null) { throw new InvalidWSDLException("Type cannot be resolved: " + typeName.toString()); } element.setSchemaType(type); element.setSchemaTypeName(type.getQName()); } } XMLType xmlType = new XMLType(getElementInfo(element)); xmlType.setNillable(element.isNillable()); xmlType.setMany(element.getMaxOccurs() > 1); dataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType); }
OMElement bodyFirstChild) throws AxisFault { long minOccurs = innerElement.getMinOccurs(); boolean nillable = innerElement.isNillable(); String name = qName != null ? qName.getLocalPart() : innerElement.getName(); Object value; OMNamespace ns = (qName == null || qName.getNamespaceURI() == null || qName.getNamespaceURI().length() == 0) ? null : soapFactory.createOMNamespace( qName.getNamespaceURI(), null);
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 (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); MessagePartInfo mpi = wrapper.addMessagePart(new QName(namespaceURI, el.getName())); mpi.setElementQName(mpi.getName()); mpi.setConcreteName(el.getWireName()); mpi.setElement(true); mpi.setXmlSchema(el);
protected void generateSchemaForSingleElement(QName schemaTypeName, String paraName, boolean isArray) throws Exception { XmlSchemaElement elt1 = new XmlSchemaElement(getXmlSchema(schemaTargetNameSpace), false); elt1.setName(paraName); elt1.setSchemaTypeName(schemaTypeName); elt1.setNillable(true); QName elementName = new QName(schemaTargetNameSpace, paraName, schema_namespace_prefix); XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace); xmlSchema.getElements().put(elementName, elt1); xmlSchema.getItems().add(elt1); typeTable.addComplexSchema(paraName, elementName); }
@Override public void writeSchema(XmlSchema root) { if (isFlat()) { return; // there is no extra level of type. } if (hasDefinedArray(root)) { return; } XmlSchemaComplexType complex = new XmlSchemaComplexType(root, true); complex.setName(getSchemaType().getLocalPart()); XmlSchemaSequence seq = new XmlSchemaSequence(); complex.setParticle(seq); AegisType componentType = getComponentType(); XmlSchemaElement element = new XmlSchemaElement(root, false); element.setName(componentType.getSchemaType().getLocalPart()); element.setSchemaTypeName(componentType.getSchemaType()); seq.getItems().add(element); if (componentType.isNillable()) { element.setNillable(true); } element.setMinOccurs(getMinOccurs()); element.setMaxOccurs(getMaxOccurs()); }
MessagePartInfo part, boolean unwrap) { Class<?> clazz = part != null ? part.getTypeClass() : null; if (clazz != null && Exception.class.isAssignableFrom(clazz) && part != null && Boolean.TRUE.equals(part.getProperty(JAXBDataBinding.class.getName() + ".CUSTOM_EXCEPTION"))) { return unmarshallException(u, source, part); QName elName = part != null ? part.getConcreteName() : null; if (clazz != null && clazz.isArray() && part != null && part.getXmlSchema() instanceof XmlSchemaElement) { XmlSchemaElement el = (XmlSchemaElement)part.getXmlSchema(); if (el.getSchemaType() instanceof XmlSchemaSimpleType && ((XmlSchemaSimpleType)el.getSchemaType()).getContent() instanceof XmlSchemaSimpleTypeList) { } else if (part.getMessageInfo().getOperation().isUnwrapped() && el.getMaxOccurs() != 1) { } else if (byte[].class == clazz && part != null && part.getTypeQName() != null && "hexBinary".equals(part.getTypeQName().getLocalPart())) {
@Override public void writeSchema(XmlSchema root) { XmlSchemaComplexType complex = new XmlSchemaComplexType(root, true); complex.setName(getSchemaType().getLocalPart()); XmlSchemaSequence sequence = new XmlSchemaSequence(); complex.setParticle(sequence); AegisType kType = getKeyType(); AegisType vType = getValueType(); XmlSchemaElement element = new XmlSchemaElement(root, false); sequence.getItems().add(element); element.setName(getEntryName().getLocalPart()); element.setMinOccurs(0); element.setMaxOccurs(Long.MAX_VALUE); XmlSchemaComplexType evType = new XmlSchemaComplexType(root, false); element.setType(evType); XmlSchemaSequence evSequence = new XmlSchemaSequence(); evType.setParticle(evSequence); createElement(root, evSequence, getKeyName(), kType, false); createElement(root, evSequence, getValueName(), vType, true); }
/** * Generate schema construct for given type * * @param localPartName */ private XmlSchemaComplexType createSchemaTypeForMethodPart(String localPartName) { XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace); QName elementName = new QName(this.schemaTargetNameSpace, localPartName, this.schema_namespace_prefix); XmlSchemaComplexType complexType = getComplexTypeForElement(xmlSchema, elementName); if (complexType == null) { complexType = new XmlSchemaComplexType(xmlSchema, false); XmlSchemaElement globalElement = new XmlSchemaElement(xmlSchema, false); globalElement.setSchemaType(complexType); globalElement.setName(localPartName); xmlSchema.getItems().add(globalElement); xmlSchema.getElements().put(elementName, globalElement); } typeTable.addComplexSchema(localPartName, elementName); return complexType; }
/** * Creates a element in a sequence for the key type and the value type. */ private void createElement(XmlSchema schema, XmlSchemaSequence seq, QName name, AegisType type, boolean optional) { XmlSchemaElement element = new XmlSchemaElement(schema, false); seq.getItems().add(element); element.setName(name.getLocalPart()); element.setSchemaTypeName(type.getSchemaType()); if (optional) { element.setMinOccurs(0); } else { element.setMinOccurs(1); } element.setMaxOccurs(1); }