Package javax.wsdl

Examples of javax.wsdl.QName


    private void addTypes(Node node, int level) throws IOException {
        if (node == null) {
            return;
        }
        // Get the kind of node (complexType, wsdl:part, etc.)
        QName nodeKind = Utils.getNodeQName(node);

        if (nodeKind != null) {
            String localPart = nodeKind.getLocalPart();
            boolean isXSD = Constants.isSchemaXSD(nodeKind.getNamespaceURI());
            if ((isXSD && localPart.equals("complexType") ||
                 localPart.equals("simpleType"))) {

                // If an extension or restriction is present,
                // create a type for the reference
                Node re = SchemaUtils.getRestrictionOrExtensionNode(node);
                if (re != null  &&
                    Utils.getAttribute(re, "base") != null) {
                    createTypeFromRef(re);
                }

                // This is a definition of a complex type.
                // Create a Type.
                createTypeFromDef(node, false, false);
            }
            else if (isXSD && localPart.equals("element")) {
                // If the element has a type/ref attribute, create
                // a Type representing the referenced type.
                if (Utils.getNodeTypeRefQName(node, "type") != null ||
                    Utils.getNodeTypeRefQName(node, "ref") != null) {
                    createTypeFromRef(node);
                }

                // If an extension or restriction is present,
                // create a type for the reference
                Node re = SchemaUtils.getRestrictionOrExtensionNode(node);
                if (re != null  &&
                    Utils.getAttribute(re, "base") != null) {
                    createTypeFromRef(re);
                }

                // Create a type representing an element.  (This may
                // seem like overkill, but is necessary to support ref=
                // and element=.
                createTypeFromDef(node, true, level > SCHEMA_LEVEL);
            }
            else if (isXSD && localPart.equals("attribute")) {
                // If the attribute has a type/ref attribute, create
                // a Type representing the referenced type.
                if (Utils.getNodeTypeRefQName(node, "type") != null) {
                    createTypeFromRef(node);
                }

                // Get the symbol table entry and make sure it is a simple
                // type
                QName refQName = Utils.getNodeTypeRefQName(node, "type");
                if (refQName != null) {
                    TypeEntry refType = getTypeEntry(refQName, false);
                    if (refType != null &&
                        refType instanceof Undefined) {
                        // Don't know what the type is.
                        // It better be simple so set it as simple
                        refType.setSimpleType(true);
                    } else if (refType == null ||
                               (!(refType instanceof BaseType) &&
                                !refType.isSimpleType())) {
                        // Problem if not simple
                        throw new IOException(
                                              JavaUtils.getMessage("AttrNotSimpleType01",
                                                                   refQName.toString()));
                    }
                }
            }
            else if (localPart.equals("part") &&
                     Constants.isWSDL(nodeKind.getNamespaceURI())) {
View Full Code Here


     * that represents a complexType, simpleType or element (for ref=).
     */
    private void createTypeFromDef(Node node, boolean isElement,
            boolean belowSchemaLevel) throws IOException {
        // Get the QName of the node's name attribute value
        QName qName = Utils.getNodeNameQName(node);
        if (qName != null) {

            // If the qname is already registered as a base type,
            // don't create a defining type/element.
            if (!isElement && btm.getBaseName(qName)!=null) {
                return;
            }

            // If the node has a type or ref attribute, get the
            // qname representing the type
            BooleanHolder forElement = new BooleanHolder();
            QName refQName = Utils.getNodeTypeRefQName(node, forElement);

            if (refQName != null) {
                // Now get the TypeEntry
                TypeEntry refType = getTypeEntry(refQName, forElement.value);

                if (!belowSchemaLevel) {
                    symbolTablePut(new DefinedElement(qName, refType, node, ""));
                }
            }  
            else {
                // Flow to here indicates no type= or ref= attribute.
               
                // See if this is an array or simple type definition.
                IntHolder numDims = new IntHolder();
                numDims.value = 0;
                QName arrayEQName = SchemaUtils.getArrayElementQName(node, numDims);

                if (arrayEQName != null) {
                    // Get the TypeEntry for the array element type
                    refQName = arrayEQName;
                    TypeEntry refType = getTypeEntry(refQName, false);
                    if (refType == null) {
                        // Not defined yet, add one
                        String baseName = btm.getBaseName(refQName);
                        if (baseName != null)
                            refType = new BaseType(refQName);
                        else
                            refType = new UndefinedType(refQName);
                        symbolTablePut(refType);
                    }

                    // Create a defined type or element that references refType
                    String dims = "";
                    while (numDims.value > 0) {
                        dims += "[]";
                        numDims.value--;
                    }

                    TypeEntry defType = null;
                    if (isElement) {
                        if (!belowSchemaLevel) {
                            defType = new DefinedElement(qName, refType, node, dims);
                        }
                    } else {
                        defType = new DefinedType(qName, refType, node, dims);
                    }
                    if (defType != null) {
                        symbolTablePut(defType);
                    }
                }
                else {

                    // Create a TypeEntry representing this  type/element
                    String baseName = btm.getBaseName(qName);
                    if (baseName != null) {
                        symbolTablePut(new BaseType(qName));
                    }
                    else {

                        // Create a type entry, set whether it should
                        // be mapped as a simple type, and put it in the
                        // symbol table.
                        TypeEntry te = null;
                        if (!isElement) {
                            te = new DefinedType(qName, node);
                           
                            // check if we are an anonymous type underneath
                            // an element.  If so, we point the refType of the
                            // element to us (the real type).
                            if (qName.getLocalPart().indexOf(ANON_TOKEN) >= 0 ) {
                                Node parent = node.getParentNode();
                                QName parentQName = Utils.getNodeNameQName(parent);
                                TypeEntry parentType = getElement(parentQName);
                                if (parentType != null) {
                                    parentType.setRefType(te);
                                }
                            }
View Full Code Here

     * another type.  Create a Type object representing this referenced type.
     */
    private void createTypeFromRef(Node node) throws IOException {
        // Get the QName of the node's type attribute value
        BooleanHolder forElement = new BooleanHolder();
        QName qName = Utils.getNodeTypeRefQName(node, forElement);
        if (qName != null) {
           
            // Get Type or Element depending on whether type attr was used.
            TypeEntry type = getTypeEntry(qName, forElement.value);
           
            // A symbol table entry is created if the TypeEntry is not found   
            if (type == null) {
                // See if this is a special QName for collections
                if (qName.getLocalPart().indexOf("[") > 0) {
                    // Get the TypeEntry for the collection element
                    QName typeAttr = Utils.getNodeTypeRefQName(node, "type");
                    TypeEntry collEl = getTypeEntry(typeAttr, false);
                    if (collEl == null) {
                        // Collection Element Type not defined yet, add one.
                        String baseName = btm.getBaseName(typeAttr);
                        if (baseName != null) {
View Full Code Here

        // If this is one of our special 'collection' qnames.
        // get the element type and append []
        if (qName.getLocalPart().indexOf("[") > 0) {
            String localPart = qName.getLocalPart().substring(0,qName.getLocalPart().indexOf("["));
            QName eQName = new QName(qName.getNamespaceURI(), localPart);
            return getJavaName(eQName) + "[]";
        }

        // Handle the special "java" namespace for types
        if (qName.getNamespaceURI().equalsIgnoreCase("java")) {
View Full Code Here

        Iterator i = parts.iterator();

        while (i.hasNext()) {
            Parameter param = new Parameter();
            Part part = (Part) i.next();
            QName elementName = part.getElementName();
            QName typeName = part.getTypeName();
            String partName = part.getName();

            // Hack alert - Try to sense "wrapped" document literal mode
            if (literal && !i.hasNext() && partName.equals("parameters"))
                wrapped = true;
           
            if (!literal || !wrapped) {
                // We're either RPC or literal + not wrapped.
               
                param.setName(partName);

                // Add this type or element name
                if (typeName != null) {
                    param.setType(getType(typeName));
                } else if (elementName != null) {
                    // Just an FYI: The WSDL spec says that for use=encoded
                    // that parts reference an abstract type using the type attr
                    // but we kinda do the right thing here, so let it go.
                    param.setType(getElement(elementName));
                }
                               
                v.add(param);
               
                continue;   // next part
            }
           
            // flow to here means literal + wrapped!
               
            // See if we can map all the XML types to java types
            // if we can, we use these as the types
            Node node = null;
            Element e;
            if (typeName != null) {
                // Since we can't (yet?) make the Axis engine generate the right
                // XML for literal parts that specify the type attribute,
                // abort processing with an error if we encounter this case
                //
                // node = getTypeEntry(typeName, false).getNode();
                throw new IOException(
                        JavaUtils.getMessage("literalTypePart00",
                                             new String[] {partName,
                                                           opName, 
                                                           bindingName}));
            }
           
            if (elementName == null) {
                throw new IOException(
                        JavaUtils.getMessage("noElemOrType",
                                             partName,
                                             opName));               
            }
           
            // Get the node which corresponds to the type entry for this
            // element.  i.e.:
            //  <part name="part" element="foo:bar"/>
            //  ...
            //  <schema targetNamespace="foo">
            //    <element name="bar"...>  <--- This one
            node = getTypeEntry(elementName, true).getNode();
           
            // Check if this element is of the form:
            //    <element name="foo" type="tns:foo_type"/>
            QName type = Utils.getNodeTypeRefQName(node, "type");
            if (type != null) {
                // If in fact we have such a type, go get the node that
                // corresponds to THAT definition.
                node = getTypeEntry(type, false).getNode();
            }
View Full Code Here

        Node node = entry.getNode();
        if (addImports || node == null || node.getOwnerDocument() == doc) {
            entry.setIsReferenced(true);
            if (entry instanceof DefinedElement) {
                BooleanHolder forElement = new BooleanHolder();
                QName referentName = Utils.getNodeTypeRefQName(node, forElement);
                if (referentName != null) {
                    TypeEntry referent = getTypeEntry(referentName, forElement.value);
                    if (referent != null) {
                        setTypeReferences(referent, doc, literal);
                    }
                }
                // If the Defined Element has an anonymous type,
                // process it with the current literal flag setting.
                QName anonQName = SchemaUtils.getElementAnonQName(entry.getNode());
                if (anonQName != null) {
                    TypeEntry anonType = getType(anonQName);
                    if (anonType != null) {
                        setTypeReferences(anonType, doc, literal);
                        return;
View Full Code Here

    /**
     * Put the given SymTabEntry into the symbol table, if appropriate. 
     */
    private void symbolTablePut(SymTabEntry entry) throws IOException {
        QName name = entry.getQName();
        if (get(name, entry.getClass()) == null) {
            // An entry of the given qname of the given type doesn't exist yet.
            if (entry instanceof Type &&
                get(name, UndefinedType.class) != null) {

                // A undefined type exists in the symbol table, which means
                // that the type is used, but we don't yet have a definition for
                // the type.  Now we DO have a definition for the type, so
                // replace the existing undefined type with the real type.

                if (((TypeEntry)get(name, UndefinedType.class)).isSimpleType() &&
                    !((TypeEntry)entry).isSimpleType()) {
                    // Problem if the undefined type was used in a
                    // simple type context.
                    throw new IOException(
                                          JavaUtils.getMessage("AttrNotSimpleType01",
                                                               name.toString()));

                }
                Vector v = (Vector) symbolTable.get(name);
                for (int i = 0; i < v.size(); ++i) {
                    Object oldEntry = v.elementAt(i);
View Full Code Here

     *   So in these circumstances, this routine is called with xsd:int to
     *   get a suitable qname (soapenc:int) which maps to Integer.
     * @param QName
     */
    public static QName getNillableQName(QName qName) {
        QName rc = new QName(qName.getNamespaceURI(), qName.getLocalPart());
        if (Constants.isSchemaXSD(rc.getNamespaceURI())) {
            String localName = rc.getLocalPart();
            if (localName.equals("int") ||
                localName.equals("long") ||
                localName.equals("short") ||
                localName.equals("float") ||
                localName.equals("double") ||
                localName.equals("boolean") ||
                localName.equals("byte")) {
                rc.setNamespaceURI(Constants.URI_CURRENT_SOAP_ENC);
            }
            else if (localName.equals("base64Binary") ||
                     localName.equals("hexBinary")) {
                rc.setNamespaceURI(Constants.URI_CURRENT_SOAP_ENC);
                rc.setLocalPart("base64");
            }
        }
       return rc;
    }
View Full Code Here

        if (localName == null) {
            return null;
        }
        String namespace = node.getNamespaceURI();

        return (new QName(namespace, localName));
    }
View Full Code Here

        // First try to get the name directly
        localName = getAttribute(node, "name");
       
        // If this fails and the node has a ref, use the ref name.
        if (localName == null) {
            QName ref = getNodeTypeRefQName(node, "ref");
            if (ref != null) {
                localName = ref.getLocalPart();
                namespace = ref.getNamespaceURI();
            }
        }
       
        // This routine may be called for complexType elements.  In some cases,
        // the complexType may be anonymous, which is why the getScopedAttribute
        // method is used.
        if (localName == null) {
            localName = "";
            Node search = node.getParentNode();
            while(search != null) {
                QName kind = getNodeQName(search);
                if (kind.getLocalPart().equals("schema")) {
                    search = null;
                } else if (kind.getLocalPart().equals("element") ||
                           kind.getLocalPart().equals("attribute")) {
                    localName = SymbolTable.ANON_TOKEN +
                        getNodeNameQName(search).getLocalPart();
                    search = search.getParentNode();
                } else if (kind.getLocalPart().equals("complexType") ||
                           kind.getLocalPart().equals("simpleType")) {
                    localName = getNodeNameQName(search).getLocalPart() + localName;
                    search = null;
                } else {
                    search = search.getParentNode();
                }
            }           
        }
        if (localName == null)
            return null;

        // Build and return the QName
        if (namespace == null) {
            namespace = getScopedAttribute(node, "targetNamespace");
        }
        return (new QName(namespace, localName));
    }
View Full Code Here

TOP

Related Classes of javax.wsdl.QName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.