Package javax.wsdl

Examples of javax.wsdl.Types


    private void readInlineSchemas(WSDLDefinition wsdlDefinition, Definition definition) {
        if (contribution == null) {
            // Check null for test cases
            return;
        }
        Types types = definition.getTypes();
        if (types != null) {
            int index = 0;
            for (Object ext : types.getExtensibilityElements()) {
                ExtensibilityElement extElement = (ExtensibilityElement)ext;
                Element element = null;
                if (XSD_QNAME_LIST.contains(extElement.getElementType())) {
                    if (extElement instanceof Schema) {
                        element = ((Schema)extElement).getElement();
View Full Code Here


        }
    }

    private void modifySchemaImportsAndIncludes(Definition definition, String name){
        // adjust the schema locations in types section
        Types types = definition.getTypes();
        if (types != null) {
            for (Iterator iter = types.getExtensibilityElements().iterator(); iter.hasNext();) {
                Object ext = iter.next();
                if (ext instanceof UnknownExtensibilityElement &&
                    XSD_QNAME_LIST.contains(((UnknownExtensibilityElement)ext).getElementType())) {
                    changeLocations(((UnknownExtensibilityElement)ext).getElement(), name);
                }
View Full Code Here

    public TypeMappingType getCorbaTypeMapping() {
        return typeMap;
    }
   
    public void attachSchema() throws Exception {
        Types types = definition.createTypes();
        Schema wsdlSchema = (Schema)
            definition.getExtensionRegistry().createExtension(Types.class,
                                                              new QName("http://www.w3.org/2001/XMLSchema",
                                                                        "schema"));
        org.w3c.dom.Element el = XmlSchemaSerializer.serializeSchema(schema, true)[0].getDocumentElement();
        wsdlSchema.setElement(el);
        types.addExtensibilityElement(wsdlSchema);
        definition.setTypes(types);
    }
View Full Code Here

                serviceLevelPolicRef = createWSPolicyRef(dImpl, policyID);
                opLevelPolicRef = createWSPolicyRef(dImpl, inputPolicyID);
            }

            // Create types
            Types types = TypesGenerator.addTypes(def, dImpl, serviceMap, typens, globalTypens, methods);
            def.setTypes(types);

//            if(!abstractWSDL)
//            {
//                table = createMessageTable(serviceMap, typens, methods);
View Full Code Here

        // globalSchema.setAttribute(XMLNS,
        // XSD_NAMESPACE);
        globalSchema.setAttribute(ELEMENT_FORM_DEFAULT,
                UNQUALIFIED);

        Types types = def.createTypes();
       

        // ==== for all the methods, write the input and output parameters
        for (int i = 0; i < methods.length; ++i) {
            String methodName = methods[i].getMethodName();

            Vector inParams = WSDLGenUtil
            .getInParams(serviceMap, methodName);
            Vector inParamNames = new Vector();
            Vector inParamDesc = new Vector();
            Vector inParamTypes = new Vector();

            for (int j = 0; j < inParams.size(); ++j) {
                inParamNames.add(((InParamObj) inParams.get(j)).getName());
                inParamDesc
                .add(((InParamObj) inParams.get(j)).getDescription());
                inParamTypes.add(((InParamObj) inParams.get(j)).getDataType()
                        .toString());
            }

            Vector outParams = WSDLGenUtil.getOutParams(serviceMap,
                    methodName);
            Vector outParamNames = new Vector();
            Vector outParamDesc = new Vector();
            Vector outParamTypes = new Vector();

            for (int j = 0; j < outParams.size(); ++j) {
                outParamNames.add(((OutParamObj) outParams.get(j)).getName());
                outParamDesc.add(((OutParamObj) outParams.get(j))
                        .getDescription());
                outParamTypes.add(((OutParamObj) outParams.get(j))
                        .getDataType().toString());
            }

            MessageObj msgObj = new MessageObj();
            msgObj.setNamespace(typens);
            // Set the method name in the message object
            msgObj.setMethodName(methodName);

            // === write all the input parameters ========
            // Input message name
            String inputMessageName = methodName
            + GFacConstants.SERVICE_IN_PARAMS_SUFFIX;

            // Set the input message name in the message object
            msgObj.setInElementName(inputMessageName);

            // local data types
            Element inputParams = doc.createElement("element");
            String inputElementName = methodName
            + GFacConstants.SERVICE_IN_PARAMS_SUFFIX;
            String inputParametersType = methodName
            + GFacConstants.SERVICE_INPUT_PARAMS_TYPE_SUFFIX;

            inputParams.setAttribute("name", inputElementName);
            inputParams.setAttribute("type", TYPENS + ":"
                    + inputParametersType);

            schema.appendChild(inputParams);
            // local data types

            msgObj.setInMsgParamNames(inParamNames);
            msgObj.setInMsgParamTypes(inParamTypes);

            Element first = doc.createElement(COMPLEX_TYPE);
            first.setAttribute("name", inputParametersType);

            Element sequence = doc.createElement("sequence");

            for (int j = 0; j < inParamNames.size(); ++j) {
                Element elem = doc.createElement("element");
                String paramName = (String) inParamNames.get(j);
                paramName = paramName.replaceAll(HYPHEN,
                        HYPHEN_REPLACEMENT);
                elem.setAttribute("name", paramName);
                String dataType = (String) inParamTypes.get(j);

                if (dataType.equals("String")) {
                    elem.setAttribute("type", XSD_STRING_TYPE);
                } else if (dataType.equals("Integer")) {
                    elem.setAttribute("type", "xsd:int");
                } else if (dataType.equals("Float")) {
                    elem.setAttribute("type", "xsd:float");
                } else if (dataType.equals("Double")) {
                    elem.setAttribute("type", "xsd:double");
                } else if (dataType.equals("Boolean")) {
                    elem.setAttribute("type", "xsd:boolean");
                } else if (dataType.equals("QName")) {
                    elem.setAttribute("type", "xsd:QName");
                } else if (dataType.equals("URI")) {
                    elem.setAttribute("type", "xsd:anyURI");
                }
                // schemas for complex types will be written later
                else if (dataType.equals("StringArray")
                        || dataType.equals("IntegerArray")
                        || dataType.equals("FloatArray")
                        || dataType.equals("DoubleArray")
                        || dataType.equals("BooleanArray")
                        || dataType.equals("QNameArray")
                        || dataType.equals("LEADFileID")
                        || dataType.equals("LEADFileIDArray")
                        || dataType.equals("LEADNameListFile")
                        || dataType.equals("LEADNameListPropertiesFile")
                        || dataType.equals("HostName")
                        || dataType.equals(GFacConstants.Types.TYPE_URI_ARRAY)
                        || dataType.equals(GFacConstants.Types.TYPE_DATAID)) {
                    elem.setAttribute("type", GLOBAL_TYPENS + ":"
                            + dataType + "Type");
                    if (!complexTypes.contains(dataType)) {
                        complexTypes.add(dataType);
                    }
                } else if (dataType.equals(GFacConstants.Types.TYPE_DATAID_ARRAY)) {
                    elem.setAttribute("type", GLOBAL_TYPENS + ":"
                            + dataType + "Type");
                    if (!complexTypes.contains(GFacConstants.Types.TYPE_DATAID_ARRAY)) {
                        complexTypes.add(GFacConstants.Types.TYPE_DATAID_ARRAY);
                    }
                    if (!complexTypes.contains(GFacConstants.Types.TYPE_DATAID)) {
                        complexTypes.add(GFacConstants.Types.TYPE_DATAID);
                    }
                } else if (dataType.equals("StringEnum")
                        || dataType.equals("IntegerEnum")
                        || dataType.equals("FloatEnum")
                        || dataType.equals("DoubleEnum")) {
                    elem.setAttribute("type", TYPENS + ":"
                            + methodName + "_" + paramName + "_" + dataType
                            + "Type");
                }else if(dataType.equals(LEAD_CROSSCUT_PARAMETERS_NAME)){
                    if(!knownTypes.containsKey(LEAD_CROSSCUT_PARAMETERS_NAME)){
                        schemaTable.add(createCorssCutSchema(doc));
                        knownTypes.put(LEAD_CROSSCUT_PARAMETERS_NAME, LEAD_CROSSCUT_PARAMETERS_NAME);
                    }
                    elem.setAttribute("type", WSDLGenerator.CROSSCUT_PREFIX + ":"
                            + LEAD_CROSSCUT_PARAMETERS_NAME);
                }else if(dataType.equals(ENDPOINT_REFERENCE_TYPE)){
                    if(!knownTypes.containsKey(ENDPOINT_REFERENCE_TYPE)){
                        schemaTable.add(createAddressingSchema(doc));
                        knownTypes.put(ENDPOINT_REFERENCE_TYPE, ENDPOINT_REFERENCE_TYPE);
                    }
                    elem.setAttribute("type", WSDLGenerator.WSA_PREFIX + ":"
                            + ENDPOINT_REFERENCE_TYPE);
                }

                Element annotation = doc
                .createElement(ANNOTATION);

                // TODO create Metadata

                WSDLGenerator.createMetadata((InParamObj) inParams.get(j), doc,
                        annotation);

                documentation = doc.createElement(DOCUMENTATION);
                documentation.appendChild(doc
                        .createTextNode((String) inParamDesc.get(j)));
                annotation.appendChild(documentation);
                elem.appendChild(annotation);
                sequence.appendChild(elem);
            } // end for inParams

            first.appendChild(sequence);
            schema.appendChild(first);

            // write the enumeration types
            for (int j = 0; j < inParamNames.size(); ++j) {
                String dataType = (String) inParamTypes.get(j);
                if (dataType.equals("StringEnum")
                        || dataType.equals("IntegerEnum")
                        || dataType.equals("FloatEnum")
                        || dataType.equals("DoubleEnum")) {
                    String paramName = (String) inParamNames.get(j);
                    ParamValueObj paramValues = WSDLGenUtil
                    .getInParamValues(serviceMap, methodName, paramName);
                    if (paramValues == null)
                        continue;
                    String[] values = paramValues.getValues();
                    String[] descs = paramValues.getDescriptions();
                    Element elem = doc.createElement(SIMPLE_TYPE);
                    elem.setAttribute("name", methodName + "_" + paramName
                            + "_" + dataType + "Type");

                    for (int k = 0; k < values.length; ++k) {
                        documentation = doc
                        .createElement(DOCUMENTATION);
                        // documentation.setAttribute(XML_LANG,
                        // ENGLISH);

                        Element value = doc.createElement("value");
                        value.appendChild(doc.createTextNode(values[k]));
                        Element description = doc.createElement("description");
                        description.appendChild(doc.createTextNode(descs[k]));
                        documentation.appendChild(value);
                        documentation.appendChild(description);
                        elem.appendChild(documentation);
                    }

                    Element restriction = doc.createElement("restriction");
                    if (dataType.equals("StringEnum")) {
                        restriction.setAttribute("base", "xsd:string");
                    } else if (dataType.equals("IntegerEnum")) {
                        restriction.setAttribute("base", "xsd:int");
                    } else if (dataType.equals("FloatEnum")) {
                        restriction.setAttribute("base", "xsd:float");
                    } else if (dataType.equals("DoubleEnum")) {
                        restriction.setAttribute("base", "xsd:double");
                    }
                    for (int k = 0; k < values.length; ++k) {
                        Element enumeration = doc.createElement("enumeration");
                        enumeration.setAttribute("value", values[k]);
                        restriction.appendChild(enumeration);
                    }
                    elem.appendChild(restriction);
                    schema.appendChild(elem);
                }
            }

            // ====== write the output parameters ==============
            // Output message name
            if (outParams.size() > 0) {
                String outputMessageName = methodName
                + GFacConstants.SERVICE_OUT_PARAMS_SUFFIX;
                // Set the output message name in the message object
                msgObj.setOutElementName(outputMessageName);
                Element outputParams = doc.createElement("element");
                String outputElementName = methodName
                + GFacConstants.SERVICE_OUT_PARAMS_SUFFIX;
                String outputParametersType = methodName
                + GFacConstants.SERVICE_OUTPUT_PARAMS_TYPE_SUFFIX;
                outputParams.setAttribute("name", outputElementName);
                outputParams.setAttribute("type", TYPENS + ":"
                        + outputParametersType);
                schema.appendChild(outputParams);
                msgObj.setOutMsgParamNames(outParamNames);
                msgObj.setOutMsgParamTypes(outParamTypes);

                // Now add the output parameters
                first = doc.createElement(COMPLEX_TYPE);
                first.setAttribute("name", outputParametersType);
                sequence = doc.createElement("sequence");

                for (int j = 0; j < outParamNames.size(); ++j) {
                    Element elem = doc.createElement("element");
                    elem.setAttribute("name", (String) outParamNames.get(j));
                    String dataType = (String) outParamTypes.get(j);

                    if (dataType.equals("String") || dataType.equals("StdOut")
                            || dataType.equals("StdErr")) {
                        elem
                        .setAttribute("type",
                                XSD_STRING_TYPE);
                    } else if (dataType.equals("Integer")) {
                        elem.setAttribute("type", "xsd:int");
                    } else if (dataType.equals("Float")) {
                        elem.setAttribute("type", "xsd:float");
                    } else if (dataType.equals("Double")) {
                        elem.setAttribute("type", "xsd:double");
                    } else if (dataType.equals("Boolean")) {
                        elem.setAttribute("type", "xsd:boolean");
                    } else if (dataType.equals("URI")) {
                        elem.setAttribute("type", "xsd:anyURI");
                    } else if (dataType.equals("QName")) {
                        elem.setAttribute("type", "xsd:QName");
                    } else if (dataType.equals("StringArray")
                            || dataType.equals("IntegerArray")
                            || dataType.equals("FloatArray")
                            || dataType.equals("DoubleArray")
                            || dataType.equals("BooleanArray")
                            || dataType.equals("QNameArray")
                            || dataType.equals("LEADFileID")
                            || dataType.equals("LEADFileIDArray")
                            || dataType.equals(GFacConstants.Types.TYPE_DATAID)
                            || dataType.equals(GFacConstants.Types.TYPE_URI_ARRAY)
                    ) {
                        elem.setAttribute("type", GLOBAL_TYPENS
                                + ":" + dataType + "Type");
                        if (!complexTypes.contains(dataType)) {
                            complexTypes.add(dataType);
                        }
                    } else if (dataType.equals(GFacConstants.Types.TYPE_DATAID_ARRAY)) {
                        elem.setAttribute("type", GLOBAL_TYPENS
                                + ":" + dataType +"Type");
                        if (!complexTypes.contains(GFacConstants.Types.TYPE_DATAID_ARRAY)) {
                            complexTypes.add(GFacConstants.Types.TYPE_DATAID_ARRAY);
                        }
                        if (!complexTypes.contains(GFacConstants.Types.TYPE_DATAID)) {
                            complexTypes.add(GFacConstants.Types.TYPE_DATAID);
                        }
                    }else if(dataType.equals(LEAD_CROSSCUT_PARAMETERS_NAME)){
                        if(!knownTypes.containsKey(LEAD_CROSSCUT_PARAMETERS_NAME)){
                            schemaTable.add(createCorssCutSchema(doc));
                            knownTypes.put(LEAD_CROSSCUT_PARAMETERS_NAME, LEAD_CROSSCUT_PARAMETERS_NAME);
                        }
                        elem.setAttribute("type", WSDLGenerator.CROSSCUT_PREFIX + ":"
                                + LEAD_CROSSCUT_PARAMETERS_NAME);
//                    }else if(dataType.equals(ENDPOINT_REFERENCE_TYPE)){
//                        if(!knownTypes.containsKey(ENDPOINT_REFERENCE_TYPE)){
//                            schemaTable.add(createAddressingSchema(doc));
//                            knownTypes.put(ENDPOINT_REFERENCE_TYPE, ENDPOINT_REFERENCE_TYPE);
//                        }
//                        elem.setAttribute("type", WSDLGenerator.WSA_PREFIX + ":"
//                                + ENDPOINT_REFERENCE_TYPE);
                    }

                    // Create an annotation
                    Element annotation = doc
                    .createElement(ANNOTATION);
                    WSDLGenerator.createMetadata(
                            (OutParamObj) outParams.get(j), doc, annotation);
                    documentation = doc
                    .createElement(DOCUMENTATION);
                    documentation.appendChild(doc
                            .createTextNode((String) outParamDesc.get(j)));
                    annotation.appendChild(documentation);
                    elem.appendChild(annotation);
                    sequence.appendChild(elem);

                } // end for outParamNames.size()
            }

            first.appendChild(sequence);
            schema.appendChild(first);

        } // end for methods.length

        // write the schemas for the complex types in the input and output
        // parameters

        for (int i = 0; i < complexTypes.size(); ++i) {
            String dataType = (String) complexTypes.get(i);

            if (dataType.equals("LEADFileID")
                    || dataType.equals("LEADNameListFile")
                    || dataType.equals("LEADNameListPropertiesFile")
                    || dataType.equals("LEADWorkflowIDType")) {
                Element first = doc.createElement(SIMPLE_TYPE);
                first.setAttribute("name", dataType + "Type");
                Element restriction = doc.createElement("restriction");
                restriction.setAttribute("base", "xsd:anyURI");
                first.appendChild(restriction);
                globalSchema.appendChild(first);
            }else if (dataType.equals("HostName")) {
                Element first = doc.createElement(SIMPLE_TYPE);
                first.setAttribute("name", dataType + "Type");
                Element restriction = doc.createElement("restriction");
                restriction.setAttribute("base", "xsd:string");
                first.appendChild(restriction);
                globalSchema.appendChild(first);
            }else if(dataType.equals(GFacConstants.Types.TYPE_DATAID)){
                Element first = doc.createElement(COMPLEX_TYPE);
                first.setAttribute("name", dataType + "Type");
                Element complexContent = doc.createElement("complexContent");
                first.appendChild(complexContent);
                Element extension = doc.createElement("extension");
                extension.setAttribute("base", "xsd:anyURI");
                complexContent.appendChild(extension);
                Element attribute = doc.createElement("attribute");
                extension.appendChild(attribute);
                attribute.setAttribute("name", DataIDType.LOCATION_ATTRIBUTE);
                attribute.setAttribute("type", "xsd:string");
                attribute.setAttribute("use", "optional");
                globalSchema.appendChild(first);
            }
        }

        for (int i = 0; i < complexTypes.size(); ++i) {
            Element first = doc.createElement(COMPLEX_TYPE);
            String dataType = (String) complexTypes.get(i);
            first.setAttribute("name", dataType + "Type");
            Element sequence = doc.createElement("sequence");
            Element elem = doc.createElement("element");
            elem.setAttribute("name", GFacConstants.ARRAY_VALUE);

            if (dataType.equals("StringArray")) {
                elem.setAttribute("type", "xsd:string");
            } else if (dataType.equals("IntegerArray")) {
                elem.setAttribute("type", "xsd:int");
            } else if (dataType.equals("FloatArray")) {
                elem.setAttribute("type", "xsd:float");
            } else if (dataType.equals("DoubleArray")) {
                elem.setAttribute("type", "xsd:double");
            } else if (dataType.equals("BooleanArray")) {
                elem.setAttribute("type", "xsd:boolean");
            } else if (dataType.equals(GFacConstants.Types.TYPE_LEADFILEID_ARRAY)
                    || dataType.equals(GFacConstants.Types.TYPE_URI_ARRAY)) {
                elem.setAttribute("type", "xsd:anyURI");
            }else if(dataType.equals(GFacConstants.Types.TYPE_DATAID_ARRAY)){
                elem.setAttribute("type", "globalTypens:"+GFacConstants.Types.TYPE_DATAID + "Type");
            } else if (dataType.equals("QNameArray")) {
                elem.setAttribute("type", "xsd:anyQName");
            } else {
                continue;
            }

            elem.setAttribute("minOccurs", "0");
            elem.setAttribute("maxOccurs", "unbounded");
            sequence.appendChild(elem);
            first.appendChild(sequence);
            globalSchema.appendChild(first);
        }

        // types.setDocumentationElement(schema);
        SchemaImpl schemaImpl = new SchemaImpl();
//        SchemaImportImpl schemaimport = new SchemaImportImpl();
//        schemaimport.setNamespaceURI("http://www.extreme.indiana.edu/lead/xsd");
//        schemaimport.setSchemaLocationURI("http://www.extreme.indiana.edu/gfac/gfac-simple-types.xsd");
//        schemaImpl.addImport(schemaimport);
       
        Element importEle = doc.createElement("import");
        importEle.setAttribute("namespace","http://www.extreme.indiana.edu/lead/xsd");
        importEle.setAttribute("schemaLocation", "http://www.extreme.indiana.edu/gfac/gfac-simple-types.xsd");
        schema.insertBefore(importEle, schema.getFirstChild());
       
        if(knownTypes.containsKey(LEAD_CROSSCUT_PARAMETERS_NAME)){
            importEle = doc.createElement("import");
            importEle.setAttribute("namespace","http://lead.extreme.indiana.edu/namespaces/2006/lead-crosscut-parameters/");
            importEle.setAttribute("schemaLocation", "http://www.extreme.indiana.edu/gfac/schemas/leadcrosscut.xsd");
            schema.insertBefore(importEle, schema.getFirstChild());
        }
       
       
        //schema.appendChild();
       

        schemaImpl.setElement(schema);
        schemaImpl.setElementType(new QName("http://www.w3.org/2001/XMLSchema",
        "schema"));

        SchemaImpl globalSchemaImpl = new SchemaImpl();
        globalSchemaImpl.setElement(globalSchema);
        globalSchemaImpl.setElementType(new QName(
                "http://www.w3.org/2001/XMLSchema", "schema"));
        globalSchemaImpl.getElement().setAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");

        types.addExtensibilityElement(schemaImpl);
        //types.addExtensibilityElement(globalSchemaImpl);

//        for(Element schemaEle:schemaTable){
//            SchemaImpl newSchema = new SchemaImpl();
//            newSchema.setElement(schemaEle);
View Full Code Here

        assert def != null;

        if (__log.isDebugEnabled())
            __log.debug("Processing XSD schemas in " + def.getDocumentBaseURI());

        Types types = def.getTypes();

        if (types != null) {
            for (Iterator<ExtensibilityElement> iter =
                    ((List<ExtensibilityElement>)def.getTypes().getExtensibilityElements()).iterator();
                 iter.hasNext();) {
View Full Code Here

        WSDLReader reader = factory.newWSDLReader();
        return reader.readWSDL(definition.getDocumentBaseURI(), root);
    }
   
    public Types createTypes(Definition definition) {
        Types types = definition.createTypes();
        definition.setTypes(types);
        return types;
    }
View Full Code Here

            }
        }
    }

    public Schema createSchemaExt(Definition definition) throws WSDLException {
        Types types = definition.getTypes();
        if (types == null) {
            types = definition.createTypes();
            definition.setTypes(types);
        }

        Schema schemaExt = createSchema(definition);
        types.addExtensibilityElement(schemaExt);

        return schemaExt;
    }
View Full Code Here

        assertEquals(4, binding.getBindingOperations().size());
    }
   
    @Test
    public void testSchemas() throws Exception {
        Types types = newDef.getTypes();
        assertNotNull(types);
        Collection<ExtensibilityElement> schemas =
            CastUtils.cast(types.getExtensibilityElements(), ExtensibilityElement.class);
        assertEquals(1, schemas.size());
        XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
        Element schemaElem = ((Schema)schemas.iterator().next()).getElement();
        assertEquals("http://apache.org/hello_world_soap_http/types",
                     schemaCollection.read(schemaElem).getTargetNamespace()
View Full Code Here

       
       
        /* This doesn't actually work.   Setting setSchemaLocationURI on the import
        * for some reason doesn't actually result in the new URI being written
        * */
        Types types = def.getTypes();
        if (types != null) {
            for (ExtensibilityElement el
                : CastUtils.cast((List)types.getExtensibilityElements(), ExtensibilityElement.class)) {
                if (el instanceof Schema) {
                    Schema see = (Schema)el;
                    updateSchemaImports(see, doneSchemas, base);
                }
            }
View Full Code Here

TOP

Related Classes of javax.wsdl.Types

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.