Java Code Examples for org.apache.cxf.service.model.MessagePartInfo#getXmlSchema()
The following examples show how to use
org.apache.cxf.service.model.MessagePartInfo#getXmlSchema() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReflectionServiceFactoryBean.java From cxf with Apache License 2.0 | 6 votes |
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); }
Example 2
Source File: ParameterProcessor.java From cxf with Apache License 2.0 | 5 votes |
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); }
Example 3
Source File: ParameterMapper.java From cxf with Apache License 2.0 | 5 votes |
public static JavaParameter map(JavaMethod jm, MessagePartInfo part, JavaType.Style style, ToolContext context) { String name = ProcessorUtil.mangleNameToVariableName(part.getName().getLocalPart()); String namespace = ProcessorUtil.resolvePartNamespace(part); String type = ProcessorUtil.resolvePartType(part, context); JavaParameter parameter = new JavaParameter(name, type, namespace); parameter.setPartName(part.getName().getLocalPart()); if (part.getXmlSchema() instanceof XmlSchemaSimpleType) { processXmlSchemaSimpleType((XmlSchemaSimpleType)part.getXmlSchema(), jm, parameter, part); } else if (part.getXmlSchema() instanceof XmlSchemaElement) { XmlSchemaElement element = (XmlSchemaElement)part.getXmlSchema(); if (element.getSchemaType() instanceof XmlSchemaSimpleType) { processXmlSchemaSimpleType((XmlSchemaSimpleType)element.getSchemaType(), jm, parameter, part); } } parameter.setQName(ProcessorUtil.getElementName(part)); parameter.setDefaultValueWriter(ProcessorUtil.getDefaultValueWriter(part, context)); String fullJavaName = ProcessorUtil.getFullClzName(part, context, false); parameter.setClassName(fullJavaName); if (style == JavaType.Style.INOUT || style == JavaType.Style.OUT) { parameter.setHolder(true); parameter.setHolderName(javax.xml.ws.Holder.class.getName()); String holderClass = fullJavaName; if (JAXBUtils.holderClass(fullJavaName) != null) { holderClass = JAXBUtils.holderClass(fullJavaName).getName(); } parameter.setClassName(holderClass); } parameter.setStyle(style); return parameter; }
Example 4
Source File: JAXBSchemaInitializer.java From cxf with Apache License 2.0 | 5 votes |
public void checkForExistence(MessagePartInfo part) { QName qn = part.getElementQName(); if (qn != null) { XmlSchemaElement el = schemas.getElementByQName(qn); if (el == null) { Class<?> clazz = part.getTypeClass(); if (clazz == null) { return; } boolean isFromWrapper = part.getMessageInfo().getOperation().isUnwrapped(); if (isFromWrapper && clazz.isArray() && !Byte.TYPE.equals(clazz.getComponentType())) { clazz = clazz.getComponentType(); } JAXBBeanInfo beanInfo = getBeanInfo(clazz); if (beanInfo == null) { if (Exception.class.isAssignableFrom(clazz)) { QName name = (QName)part.getMessageInfo().getProperty("elementName"); part.setElementQName(name); buildExceptionType(part, clazz); } return; } QName typeName = getTypeName(beanInfo); createBridgeXsElement(part, qn, typeName); } else if (part.getXmlSchema() == null) { part.setXmlSchema(el); } } }
Example 5
Source File: DataWriterImpl.java From cxf with Apache License 2.0 | 5 votes |
private boolean needToRender(MessagePartInfo part) { if (part != null && part.getXmlSchema() instanceof XmlSchemaElement) { XmlSchemaElement element = (XmlSchemaElement)part.getXmlSchema(); return element.isNillable() && element.getMinOccurs() > 0; } return false; }
Example 6
Source File: DocLiteralInInterceptor.java From cxf with Apache License 2.0 | 5 votes |
private void getPara(DepthXMLStreamReader xmlReader, DataReader<XMLStreamReader> dr, MessageContentsList parameters, Iterator<MessagePartInfo> itr, Message message) { boolean hasNext = true; while (itr.hasNext()) { MessagePartInfo part = itr.next(); if (hasNext) { hasNext = StaxUtils.toNextElement(xmlReader); } Object obj = null; if (hasNext) { QName rname = xmlReader.getName(); while (part != null && !rname.equals(part.getConcreteName())) { if (part.getXmlSchema() instanceof XmlSchemaElement) { //TODO - should check minOccurs=0 and throw validation exception //thing if the part needs to be here parameters.put(part, null); } if (itr.hasNext()) { part = itr.next(); } else { part = null; } } if (part == null) { return; } if (rname.equals(part.getConcreteName())) { obj = dr.read(part, xmlReader); } } parameters.put(part, obj); } }
Example 7
Source File: AegisDatabinding.java From cxf with Apache License 2.0 | 4 votes |
protected void initializeMessage(Service s, TypeMapping serviceTM, AbstractMessageContainer container, int partType, Set<AegisType> deps) { if (container == null) { return; } for (MessagePartInfo part : container.getMessageParts()) { AegisType type = getParameterType(s, serviceTM, part, partType); if (part.getXmlSchema() == null) { // schema hasn't been filled in yet if (type.isAbstract()) { part.setTypeQName(type.getSchemaType()); } else { part.setElementQName(type.getSchemaType()); } } Annotation[] anns = part.getProperty("parameter.annotations", Annotation[].class); long miValue = -1; if (type.hasMinOccurs()) { miValue = type.getMinOccurs(); } Integer i = AnnotationReader.getMinOccurs(anns); if (i != null) { miValue = i; } if (miValue > 0) { part.setProperty("minOccurs", Long.toString(miValue)); } // The concept of type.isNillable is questionable: how are types nillable? // However, this if at least allow .aegis.xml files to get control. if (part.getProperty("nillable") == null) { boolean isNil = type.isNillable(); Boolean b = AnnotationReader.isNillable(anns); if (b != null || (miValue != 0 && isNil)) { part.setProperty("nillable", b == null ? isNil : b); } /* if (miValue == -1 && (b == null ? isNil : b)) { part.setProperty("minOccurs", "1"); } */ } if (type.hasMaxOccurs()) { String moValue; long mo = type.getMaxOccurs(); if (mo != Long.MAX_VALUE) { moValue = Long.toString(mo); part.setProperty("maxOccurs", moValue); } } part2Type.put(part, type); // QName elName = getSuggestedName(service, op, param) deps.add(type); type.getTypeMapping().register(type); addDependencies(deps, type); } }
Example 8
Source File: DataWriterImpl.java From cxf with Apache License 2.0 | 4 votes |
public void write(Object obj, MessagePartInfo part, T output) { boolean honorJaxbAnnotation = honorJAXBAnnotations(part); if (part != null && !part.isElement() && part.getTypeClass() != null) { honorJaxbAnnotation = true; } checkPart(part, obj); if (obj != null || !(part.getXmlSchema() instanceof XmlSchemaElement)) { if (obj instanceof Exception && part != null && Boolean.TRUE.equals(part.getProperty(JAXBDataBinding.class.getName() + ".CUSTOM_EXCEPTION"))) { JAXBEncoderDecoder.marshallException(createMarshaller(obj, part), (Exception)obj, part, output); onCompleteMarshalling(); } else { Annotation[] anns = getJAXBAnnotation(part); if (!honorJaxbAnnotation || anns.length == 0) { JAXBEncoderDecoder.marshall(createMarshaller(obj, part), obj, part, output); onCompleteMarshalling(); } else if (honorJaxbAnnotation && anns.length > 0) { //RpcLit will use the JAXB Bridge to marshall part message when it is //annotated with @XmlList,@XmlAttachmentRef,@XmlJavaTypeAdapter //TODO:Cache the JAXBRIContext JAXBEncoderDecoder.marshalWithBridge(part.getConcreteName(), part.getTypeClass(), anns, databinding.getContextClasses(), obj, output, getAttachmentMarshaller()); } } } else if (needToRender(part)) { JAXBEncoderDecoder.marshallNullElement(createMarshaller(null, part), output, part); onCompleteMarshalling(); } }
Example 9
Source File: ReflectionServiceFactoryBean.java From cxf with Apache License 2.0 | 4 votes |
protected void createBareMessage(ServiceInfo serviceInfo, OperationInfo opInfo, boolean isOut) { MessageInfo message = isOut ? opInfo.getOutput() : opInfo.getInput(); final List<MessagePartInfo> messageParts = message.getMessageParts(); if (messageParts.isEmpty()) { return; } Method method = (Method)opInfo.getProperty(METHOD); int paraNumber = 0; for (MessagePartInfo mpi : messageParts) { SchemaInfo schemaInfo = null; XmlSchema schema = null; QName qname = (QName)mpi.getProperty(ELEMENT_NAME); if (messageParts.size() == 1 && qname == null) { qname = !isOut ? getInParameterName(opInfo, method, -1) : getOutParameterName(opInfo, method, -1); if (qname.getLocalPart().startsWith("arg") || qname.getLocalPart().startsWith("return")) { qname = isOut ? new QName(qname.getNamespaceURI(), method.getName() + "Response") : new QName(qname .getNamespaceURI(), method.getName()); } } else if (isOut && messageParts.size() > 1 && qname == null) { while (!isOutParam(method, paraNumber)) { paraNumber++; } qname = getOutParameterName(opInfo, method, paraNumber); } else if (qname == null) { qname = getInParameterName(opInfo, method, paraNumber); } for (SchemaInfo s : serviceInfo.getSchemas()) { if (s.getNamespaceURI().equals(qname.getNamespaceURI())) { schemaInfo = s; break; } } if (schemaInfo == null) { schemaInfo = getOrCreateSchema(serviceInfo, qname.getNamespaceURI(), true); schema = schemaInfo.getSchema(); } else { schema = schemaInfo.getSchema(); if (schema != null && schema.getElementByName(qname) != null) { mpi.setElement(true); mpi.setElementQName(qname); mpi.setXmlSchema(schema.getElementByName(qname)); paraNumber++; continue; } } schemaInfo.setElement(null); //cached element is now invalid XmlSchemaElement el = new XmlSchemaElement(schema, true); el.setName(qname.getLocalPart()); el.setNillable(true); if (mpi.isElement()) { XmlSchemaElement oldEl = (XmlSchemaElement)mpi.getXmlSchema(); if (null != oldEl && !oldEl.getQName().equals(qname)) { el.setSchemaTypeName(oldEl.getSchemaTypeName()); el.setSchemaType(oldEl.getSchemaType()); if (oldEl.getSchemaTypeName() != null) { addImport(schema, oldEl.getSchemaTypeName().getNamespaceURI()); } } mpi.setElement(true); mpi.setXmlSchema(el); mpi.setElementQName(qname); mpi.setConcreteName(qname); continue; } if (null == mpi.getTypeQName() && mpi.getXmlSchema() == null) { throw new ServiceConstructionException(new Message("UNMAPPABLE_PORT_TYPE", LOG, method.getDeclaringClass().getName(), method.getName(), mpi.getName())); } if (mpi.getTypeQName() != null) { el.setSchemaTypeName(mpi.getTypeQName()); } else { el.setSchemaType((XmlSchemaType)mpi.getXmlSchema()); } mpi.setXmlSchema(el); mpi.setConcreteName(qname); if (mpi.getTypeQName() != null) { addImport(schema, mpi.getTypeQName().getNamespaceURI()); } mpi.setElement(true); mpi.setElementQName(qname); paraNumber++; } }