Search in sources :

Example 1 with ExplicitGroup

use of org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.ExplicitGroup in project metro-jax-ws by eclipse-ee4j.

the class ServiceArtifactSchemaGenerator method addChild.

protected void addChild(ExplicitGroup sq, ParameterImpl param) {
    TypeInfo typeInfo = param.getItemType();
    boolean repeatedElement = false;
    if (typeInfo == null) {
        typeInfo = param.getTypeInfo();
    } else {
        if (typeInfo.getWrapperType() != null)
            typeInfo = param.getTypeInfo();
        else
            repeatedElement = true;
    }
    Occurs child = addChild(sq, param.getName(), typeInfo);
    if (repeatedElement && child != null) {
        child.maxOccurs("unbounded");
    }
}
Also used : Occurs(org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Occurs)

Example 2 with ExplicitGroup

use of org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.ExplicitGroup in project metro-jax-ws by eclipse-ee4j.

the class ServiceArtifactSchemaGenerator method addChild.

protected Occurs addChild(ExplicitGroup sq, QName name, TypeInfo typeInfo) {
    LocalElement le = null;
    QName type = model.getBindingContext().getTypeName(typeInfo);
    if (type != null) {
        le = sq.element();
        le._attribute("name", name.getLocalPart());
        le.type(type);
    } else {
        if (typeInfo.type instanceof Class) {
            try {
                QName elemName = model.getBindingContext().getElementName((Class) typeInfo.type);
                if (elemName.getLocalPart().equals("any") && elemName.getNamespaceURI().equals(WSDLGenerator.XsdNs)) {
                    return sq.any();
                } else {
                    le = sq.element();
                    le.ref(elemName);
                }
            } catch (JAXBException je) {
                throw new WebServiceException(je.getMessage(), je);
            }
        }
    }
    return le;
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) LocalElement(org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.LocalElement) JAXBException(jakarta.xml.bind.JAXBException)

Example 3 with ExplicitGroup

use of org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.ExplicitGroup in project metro-jax-ws by eclipse-ee4j.

the class ServiceArtifactSchemaGenerator method generate.

public void generate(SchemaOutputResolver resolver) {
    xsdResolver = resolver;
    List<WrapperParameter> wrappers = new ArrayList<>();
    for (JavaMethodImpl method : model.getJavaMethods()) {
        if (method.getBinding().isRpcLit())
            continue;
        for (ParameterImpl p : method.getRequestParameters()) {
            if (p instanceof WrapperParameter) {
                if (WrapperComposite.class.equals((p.getTypeInfo().type))) {
                    wrappers.add((WrapperParameter) p);
                }
            }
        }
        for (ParameterImpl p : method.getResponseParameters()) {
            if (p instanceof WrapperParameter) {
                if (WrapperComposite.class.equals((p.getTypeInfo().type))) {
                    wrappers.add((WrapperParameter) p);
                }
            }
        }
    }
    if (wrappers.isEmpty())
        return;
    HashMap<String, Schema> xsds = initWrappersSchemaWithImports(wrappers);
    postInit(xsds);
    for (WrapperParameter wp : wrappers) {
        String tns = wp.getName().getNamespaceURI();
        Schema xsd = xsds.get(tns);
        Element e = xsd._element(Element.class);
        e._attribute("name", wp.getName().getLocalPart());
        e.type(wp.getName());
        ComplexType ct = xsd._element(ComplexType.class);
        ct._attribute("name", wp.getName().getLocalPart());
        ExplicitGroup sq = ct.sequence();
        for (ParameterImpl p : wp.getWrapperChildren()) if (p.getBinding().isBody())
            addChild(sq, p);
    }
    for (Schema xsd : xsds.values()) xsd.commit();
}
Also used : JavaMethodImpl(com.sun.xml.ws.model.JavaMethodImpl) ParameterImpl(com.sun.xml.ws.model.ParameterImpl) Schema(com.sun.xml.ws.wsdl.writer.document.xsd.Schema) LocalElement(org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.LocalElement) Element(org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Element) ArrayList(java.util.ArrayList) WrapperParameter(com.sun.xml.ws.model.WrapperParameter) ComplexType(org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.ComplexType) ExplicitGroup(org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.ExplicitGroup)

Aggregations

LocalElement (org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.LocalElement)2 JavaMethodImpl (com.sun.xml.ws.model.JavaMethodImpl)1 ParameterImpl (com.sun.xml.ws.model.ParameterImpl)1 WrapperParameter (com.sun.xml.ws.model.WrapperParameter)1 Schema (com.sun.xml.ws.wsdl.writer.document.xsd.Schema)1 JAXBException (jakarta.xml.bind.JAXBException)1 WebServiceException (jakarta.xml.ws.WebServiceException)1 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 ComplexType (org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.ComplexType)1 Element (org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Element)1 ExplicitGroup (org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.ExplicitGroup)1 Occurs (org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Occurs)1