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

The following examples show how to use org.apache.cxf.service.model.MessagePartInfo#getName() . 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 vote down vote up
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: DataWriterImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void checkPart(MessagePartInfo part, Object object) {
    if (part == null || part.getTypeClass() == null || object == null) {
        return;
    }
    Class<?> typeClass = part.getTypeClass();
    if (typeClass == null) {
        return;
    }
    if (typeClass.isPrimitive()) {
        if (typeClass == Long.TYPE) {
            typeClass = Long.class;
        } else if (typeClass == Integer.TYPE) {
            typeClass = Integer.class;
        } else if (typeClass == Short.TYPE) {
            typeClass = Short.class;
        } else if (typeClass == Byte.TYPE) {
            typeClass = Byte.class;
        } else if (typeClass == Character.TYPE) {
            typeClass = Character.class;
        } else if (typeClass == Double.TYPE) {
            typeClass = Double.class;
        } else if (typeClass == Float.TYPE) {
            typeClass = Float.class;
        } else if (typeClass == Boolean.TYPE) {
            typeClass = Boolean.class;
        }
    } else if (typeClass.isArray() && object instanceof Collection) {
        //JAXB allows a pseudo [] <--> List equivalence
        return;
    }
    if (!typeClass.isInstance(object)) {
        throw new IllegalArgumentException("Part " + part.getName() + " should be of type "
            + typeClass.getName() + ", not "
            + object.getClass().getName());
    }
}
 
Example 3
Source File: CorbaStreamOutEndingInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected QName getMessageParamQName(MessageInfo msgInfo,
                                     String paramName,
                                     int index) {
    QName paramQName = null;
    MessagePartInfo part = msgInfo.getMessageParts().get(index);
    if (part != null && part.isElement()) {
        paramQName = part.getElementQName();
    } else if (part != null)  {
        paramQName = part.getName();
    }
    return paramQName;
}
 
Example 4
Source File: CorbaStreamInInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected QName getMessageParamQName(MessageInfo msgInfo,
                                     String paramName,
                                     int index) {
    QName paramQName = null;
    MessagePartInfo part = msgInfo.getMessageParts().get(index);
    if (part != null && part.isElement()) {
        paramQName = part.getElementQName();
    } else if (part != null) {
        paramQName = part.getName();
    }
    return paramQName;
}
 
Example 5
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++;
        }
    }