Java Code Examples for org.apache.cxf.service.model.MessagePartInfo#getTypeQName()

The following examples show how to use org.apache.cxf.service.model.MessagePartInfo#getTypeQName() . 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: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void buildMessage(Message message,
                            AbstractMessageContainer messageContainer,
                            final Definition def) {
    addDocumentation(message, messageContainer.getMessageDocumentation());
    message.setQName(messageContainer.getName());
    message.setUndefined(false);
    def.addMessage(message);

    List<MessagePartInfo> messageParts = messageContainer.getMessageParts();
    Part messagePart = null;
    for (MessagePartInfo messagePartInfo : messageParts) {
        messagePart = def.createPart();
        messagePart.setName(messagePartInfo.getName().getLocalPart());
        if (messagePartInfo.isElement()) {
            messagePart.setElementName(messagePartInfo.getElementQName());
            addNamespace(messagePartInfo.getElementQName().getNamespaceURI(), def);
        } else if (messagePartInfo.getTypeQName() != null) {
            messagePart.setTypeName(messagePartInfo.getTypeQName());
            addNamespace(messagePartInfo.getTypeQName().getNamespaceURI(), def);
        }
        message.addPart(messagePart);
    }
}
 
Example 2
Source File: ProcessorUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static String resolvePartType(MessagePartInfo part, ToolContext context, boolean fullName) {
    DataBindingProfile dataBinding = context.get(DataBindingProfile.class);
    if (dataBinding == null) {
        String primitiveType = JAXBUtils.builtInTypeToJavaType(part.getTypeQName().getLocalPart());
        if (part.getTypeQName() != null &&  primitiveType != null) {
            return primitiveType;
        }
        return resolvePartType(part);
    }
    String name = "";
    if (part.isElement()) {
        name = dataBinding.getType(getElementName(part), true);
    } else {
        name = dataBinding.getType(part.getTypeQName(), false);
    }
    if (name == null) {
        String namespace = resolvePartNamespace(part);
        if ("http://www.w3.org/2005/08/addressing".equals(namespace)) {
            //The ws-addressing stuff isn't mapped in jaxb as jax-ws specifies they
            //need to be mapped differently
            String pn = part.getConcreteName().getLocalPart();
            if ("EndpointReference".equals(pn)
                || "ReplyTo".equals(pn)
                || "From".equals(pn)
                || "FaultTo".equals(pn)) {

                name = "javax.xml.ws.wsaddressing.W3CEndpointReference";
            }
        }

    }
    return name;
}
 
Example 3
Source File: ParameterProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean isSamePart(MessagePartInfo part1, MessagePartInfo part2) {
    QName qname1 = part1.getElementQName();
    QName qname2 = part2.getElementQName();
    QName tname1 = part1.getTypeQName();
    QName tname2 = part2.getTypeQName();
    if (qname1 != null && qname2 != null) {
        return qname1.equals(qname2) && (tname1 == null || tname1.equals(tname2));
    }
    if (tname1 != null && tname2 != null) {
        return tname1.equals(tname2);
    }
    return false;
}
 
Example 4
Source File: ReflectionServiceFactoryBean.java    From cxf with Apache License 2.0 4 votes vote down vote up
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++;
        }
    }