⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 javastubwriter.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                    pw.println("        oper.setReturnHeader(true);");                }                QName itemQName = Utils.getItemQName(returnParam.getType());                if (itemQName != null) {                    pw.println("        param = oper.getReturnParamDesc();");                    pw.println("        param.setItemQName(" +                               Utils.getNewQName(itemQName) + ");");                }            } else {                pw.println(                        "        oper.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID);");            }            boolean hasMIME = Utils.hasMIME(bEntry, operation);            Style style = Style.getStyle(opStyle, bEntry.getBindingStyle());            Use use = bEntry.getInputBodyType(operation.getOperation());            if ((style == Style.DOCUMENT) && symbolTable.isWrapped()) {                style = Style.WRAPPED;            }            if (!hasMIME) {                pw.println("        oper.setStyle(" + styles.get(style) + ");");                pw.println("        oper.setUse(" + uses.get(use) + ");");            }            // Register fault/exception information for this operation            writeFaultInfo(pw, operation);            pw.println(indent + "_operations[" + i + "] = oper;");            pw.println("");        }        pw.println("    }");    }    /**     * This method returns a set of all the TypeEntry in a given PortType.     * The elements of the returned HashSet are Types.     *      * @param portType      * @return      */    private HashSet getTypesInPortType(PortType portType) {        HashSet types = new HashSet();        HashSet firstPassTypes = new HashSet();        // Get all the types from all the operations        List operations = portType.getOperations();        for (int i = 0; i < operations.size(); ++i) {            Operation op = (Operation) operations.get(i);            firstPassTypes.addAll(getTypesInOperation(op));        }        // Add all the types nested and derived from the types        // in the first pass.        Iterator i = firstPassTypes.iterator();        while (i.hasNext()) {            TypeEntry type = (TypeEntry) i.next();            if (!types.contains(type)) {                types.add(type);                types.addAll(type.getNestedTypes(symbolTable, true));            }        }         if(emitter.isAllWanted()) {             HashMap rawSymbolTable = symbolTable.getHashMap();             for(Iterator j = rawSymbolTable.values().iterator(); j.hasNext(); ) {                 Vector typeVector = (Vector)j.next();                 for(Iterator k = typeVector.iterator(); k.hasNext(); ) {                     Object symbol = k.next();                     if(symbol instanceof DefinedType) {                         TypeEntry type = (TypeEntry)symbol;                         if(!types.contains(type)) {                             types.add(type);                         }                     }                 }             }         }                return types;    }    // getTypesInPortType    /**     * This method returns a set of all the TypeEntry in a given Operation.     * The elements of the returned HashSet are TypeEntry.     *      * @param operation      * @return      */    private HashSet getTypesInOperation(Operation operation) {        HashSet types = new HashSet();        Vector v = new Vector();        Parameters params = bEntry.getParameters(operation);        // Loop over parameter types for this operation        for (int i = 0; i < params.list.size(); i++) {            Parameter p = (Parameter) params.list.get(i);            v.add(p.getType());        }        // Add the return type        if (params.returnParam != null) {            v.add(params.returnParam.getType());        }        // Collect all the types in faults        Map faults = operation.getFaults();        if (faults != null) {            Iterator i = faults.values().iterator();            while (i.hasNext()) {                Fault f = (Fault) i.next();                partTypes(v, f.getMessage().getOrderedParts(null));            }        }        // Put all these types into a set.  This operation eliminates all duplicates.        for (int i = 0; i < v.size(); i++) {            types.add(v.get(i));        }        return types;    }    // getTypesInOperation    /**     * This method returns a vector of TypeEntry for the parts.     *      * @param v          * @param parts      */    private void partTypes(Vector v, Collection parts) {        Iterator i = parts.iterator();        while (i.hasNext()) {            Part part = (Part) i.next();            QName qType = part.getTypeName();            if (qType != null) {                v.add(symbolTable.getType(qType));            } else {                qType = part.getElementName();                if (qType != null) {                    v.add(symbolTable.getElement(qType));                }            }        }    // while    }        // partTypes    /**     * This function writes the regsiterFaultInfo API calls     *      * @param pw          * @param bindOp      */    protected void writeFaultInfo(PrintWriter pw, BindingOperation bindOp) {        Map faultMap = bEntry.getFaults();        // Get the list of faults for this operation        ArrayList faults = (ArrayList) faultMap.get(bindOp);        // check for no faults        if (faults == null) {            return;        }        // For each fault, register its information        for (Iterator faultIt = faults.iterator(); faultIt.hasNext();) {            FaultInfo info = (FaultInfo) faultIt.next();            QName qname = info.getQName();            Message message = info.getMessage();            // if no parts in fault, skip it!            if (qname == null) {                continue;            }            // Get the Exception class name            String className = Utils.getFullExceptionName(message, symbolTable);            // output the registration API call            pw.println(                    "        oper.addFault(new org.apache.axis.description.FaultDesc(");            pw.println("                      " + Utils.getNewQName(qname)                    + ",");            pw.println("                      \"" + className + "\",");            pw.println("                      "                    + Utils.getNewQName(info.getXMLType()) + ", ");            pw.println("                      "                    + Utils.isFaultComplex(message, symbolTable));            pw.println("                     ));");        }    }    /**     * In the stub constructor, write the serializer code for the complex types.     *      * @param pw             * @param hasMIME        * @param namespace      */    protected void writeSerializationDecls(PrintWriter pw, boolean hasMIME,                                         String namespace) {        pw.println("            java.lang.Class cls;");        pw.println("            javax.xml.namespace.QName qName;");        pw.println("            javax.xml.namespace.QName qName2;");        pw.println(                "            java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class;");        pw.println(                "            java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class;");        pw.println(                "            java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class;");        pw.println(                "            java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class;");        pw.println(                "            java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class;");        pw.println(                "            java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class;");        pw.println(                "            java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class;");        pw.println(                "            java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class;");        pw.println(                "            java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class;");        pw.println(                "            java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class;");                if (hasMIME) {            pw.println(                    "            java.lang.Class mimesf = org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory.class;");            pw.println(                    "            java.lang.Class mimedf = org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory.class;");            pw.println();            QName qname = new QName(namespace, "DataHandler");            pw.println("            qName = new javax.xml.namespace.QName(\""                    + qname.getNamespaceURI() + "\", \""                    + qname.getLocalPart() + "\");");            pw.println("            cachedSerQNames.add(qName);");            pw.println("            cls = javax.activation.DataHandler.class;");            pw.println("            cachedSerClasses.add(cls);");            pw.println("            cachedSerFactories.add(mimesf);");            pw.println("            cachedDeserFactories.add(mimedf);");            pw.println();        }    }    // writeSerializationDecls    /**     * Method writeSerializationInit     *      * @param pw        * @param type      */    protected void writeSerializationInit(PrintWriter pw, TypeEntry type) {        QName qname = type.getQName();        pw.println("            qName = new javax.xml.namespace.QName(\""                + qname.getNamespaceURI() + "\", \"" + qname.getLocalPart()                + "\");");        pw.println("            cachedSerQNames.add(qName);");        pw.println("            cls = " + type.getName() + ".class;");        pw.println("            cachedSerClasses.add(cls);");        if (type.getName().endsWith("[]")) {            if (SchemaUtils.isListWithItemType(type.getNode())) {                pw.println("            cachedSerFactories.add(simplelistsf);");                pw.println("            cachedDeserFactories.add(simplelistdf);");            } else {                // We use a custom serializer if WSDL told us the component type of the array.                // Both factories must be an instance, so we create a ArrayDeserializerFactory                if (type.getComponentType() != null) {                    QName ct = type.getComponentType();                    QName name = type.getItemQName();                    pw.println("            qName = new javax.xml.namespace.QName(\""                            + ct.getNamespaceURI() + "\", \"" + ct.getLocalPart()                            + "\");");                    if(name != null) {                        pw.println("            qName2 = new javax.xml.namespace.QName(\""                                + name.getNamespaceURI() + "\", \"" + name.getLocalPart()                                + "\");");                    } else {                        pw.println("            qName2 = null;");                    }                    pw.println("            cachedSerFactories.add(new org.apache.axis.encoding.ser.ArraySerializerFactory(qName, qName2));");                    pw.println("            cachedDeserFactories.add(new org.apache.axis.encoding.ser.ArrayDeserializerFactory());");                } else {                    pw.println("            cachedSerFactories.add(arraysf);");                    pw.println("            cachedDeserFactories.add(arraydf);");                }            }        } else if ((type.getNode() != null) && (Utils.getEnumerationBaseAndValues(                type.getNode(), symbolTable) != null)) {            pw.println("            cachedSerFactories.add(enumsf);");            pw.println("            cachedDeserFactories.add(enumdf);");        } else if (type.isSimpleType()) {            pw.println("            cachedSerFactories.add(org.apache.axis.encoding.ser.BaseSerializerFactory.createFactory(" +                    "org.apache.axis.encoding.ser.SimpleSerializerFactory.class, cls, qName));");            pw.println("            cachedDeserFactories.add(org.apache.axis.encoding.ser.BaseDeserializerFactory.createFactory(" +                    "org.apache.axis.encoding.ser.SimpleDeserializerFactory.class, cls, qName));");        } else if (type.getBaseType() != null) {            // serializers are not required for types derived from base types            // java type to qname mapping is anyway established by default            // note that we have to add null to the serfactories vector to            // keep the order of other entries, this is not going to screw            // up because if type mapping returns null for a serialization            // factory, it is assumed to be not-defined and the delegate            // will be checked, the end delegate is DefaultTypeMappingImpl            // that'll get it right with the base type name            pw.println("            cachedSerFactories.add(null);");            pw.println("            cachedDeserFactories.add(simpledf);");        } else {            pw.println("            cachedSerFactories.add(beansf);");            pw.println("            cachedDeserFactories.add(beandf);");        }        pw.println();    }    // writeSerializationInit    /**     * Write the stub code for the given operation.     *      * @param pw              * @param operation       * @param parms           * @param soapAction 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -