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

📄 javaskelwriter.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                        + javaOpName + "\")).add(_oper);");            }            // Now generate FaultDesc            if (bEntry.getFaults() != null) {                ArrayList faults =                        (ArrayList) bEntry.getFaults().get(bindingOper);                if (faults != null) {                    // Operation was not created if there were no parameters                    if (parameters == null) {                        String opName =                                bindingOper.getOperation().getName();                        String javaOpName = Utils.xmlNameToJava(opName);                        pw.println(                                "        _oper = "                                + "new org.apache.axis.description.OperationDesc();");                        pw.println("        _oper.setName(\"" + javaOpName                                + "\");");                    }                    // Create FaultDesc items for each fault                    Iterator it = faults.iterator();                    while (it.hasNext()) {                        FaultInfo faultInfo = (FaultInfo) it.next();                        QName faultQName = faultInfo.getQName();                        QName faultXMLType = faultInfo.getXMLType();                        String faultName = faultInfo.getName();                        String className =                                Utils.getFullExceptionName(faultInfo.getMessage(),                                        symbolTable);                        pw.println(                                "        _fault = "                                + "new org.apache.axis.description.FaultDesc();");                        if (faultName != null) {                            pw.println("        _fault.setName(\"" + faultName                                    + "\");");                        }                        if (faultQName != null) {                            pw.println("        _fault.setQName("                                    + Utils.getNewQName(faultQName) + ");");                        }                        if (className != null) {                            pw.println("        _fault.setClassName(\""                                    + className + "\");");                        }                        if (faultXMLType != null) {                            pw.println("        _fault.setXmlType("                                    + Utils.getNewQName(faultXMLType)                                    + ");");                        }                        pw.println("        _oper.addFault(_fault);");                    }                }            }        }        pw.println("    }");        pw.println();        // Skeleton constructors         pw.println("    public " + className + "() {");		// Use custom implementation class if available.		String implementationClassName = emitter.getImplementationClassName(); 		if ( implementationClassName == null)			implementationClassName = bEntry.getName() + "Impl";        pw.println("        this.impl = new " + implementationClassName + "();");        pw.println("    }");                pw.println();        pw.println("    public " + className + "(" + implType + ") {");        pw.println("        this.impl = impl;");        pw.println("    }");        // Now write each of the operation methods        for (int i = 0; i < operations.size(); ++i) {            BindingOperation operation = (BindingOperation) operations.get(i);            Parameters parameters =                    bEntry.getParameters(operation.getOperation());            // Get the soapAction from the <soap:operation>            String soapAction = "";            Iterator operationExtensibilityIterator =                    operation.getExtensibilityElements().iterator();            for (; operationExtensibilityIterator.hasNext();) {                Object obj = operationExtensibilityIterator.next();                if (obj instanceof SOAPOperation) {                    soapAction = ((SOAPOperation) obj).getSoapActionURI();                    break;                } else if (obj instanceof UnknownExtensibilityElement) {                    // TODO: After WSDL4J supports soap12, change this code                    UnknownExtensibilityElement unkElement =                            (UnknownExtensibilityElement) obj;                    QName name =                            unkElement.getElementType();                    if (name.getNamespaceURI().equals(Constants.URI_WSDL12_SOAP)                            && name.getLocalPart().equals("operation")) {                        if (unkElement.getElement().getAttribute("soapAction")                                != null) {                            soapAction = unkElement.getElement().getAttribute(                                    "soapAction");                        }                    }                }            }            // Get the namespace for the operation from the <soap:body>            // RJB: is this the right thing to do?            String namespace = "";            Iterator bindingMsgIterator = null;            BindingInput input = operation.getBindingInput();            BindingOutput output;            if (input != null) {                bindingMsgIterator =                        input.getExtensibilityElements().iterator();            } else {                output = operation.getBindingOutput();                if (output != null) {                    bindingMsgIterator =                            output.getExtensibilityElements().iterator();                }            }            if (bindingMsgIterator != null) {                for (; bindingMsgIterator.hasNext();) {                    Object obj = bindingMsgIterator.next();                    if (obj instanceof SOAPBody) {                        namespace = ((SOAPBody) obj).getNamespaceURI();                        if (namespace == null) {                            namespace =                                    symbolTable.getDefinition().getTargetNamespace();                        }                        if (namespace == null) {                            namespace = "";                        }                        break;                    } else if (obj instanceof UnknownExtensibilityElement) {                        // TODO: After WSDL4J supports soap12, change this code                        UnknownExtensibilityElement unkElement =                                (UnknownExtensibilityElement) obj;                        QName name =                                unkElement.getElementType();                        if (name.getNamespaceURI().equals(                                Constants.URI_WSDL12_SOAP)                                && name.getLocalPart().equals("body")) {                            namespace = unkElement.getElement().getAttribute(                                    "namespace");                            if (namespace == null) {                                namespace =                                        symbolTable.getDefinition().getTargetNamespace();                            }                            if (namespace == null) {                                namespace = "";                            }                            break;                        }                    }                }            }            Operation ptOperation = operation.getOperation();            OperationType type = ptOperation.getStyle();            // These operation types are not supported.  The signature            // will be a string stating that fact.            if ((OperationType.NOTIFICATION.equals(type))                    || (OperationType.SOLICIT_RESPONSE.equals(type))) {                pw.println(parameters.signature);                pw.println();            } else {                writeOperation(pw, operation, parameters, soapAction,                        namespace);            }        }    }    // writeFileBody    /**     * Write the skeleton code for the given operation.     *      * @param pw              * @param operation       * @param parms           * @param soapAction      * @param namespace       */    protected void writeOperation(PrintWriter pw, BindingOperation operation,                                Parameters parms, String soapAction,                                String namespace) {        writeComment(pw, operation.getDocumentationElement(), true);        // The skeleton used to have specialized operation signatures.        // now the same signature is used as the portType        pw.println(parms.signature);        pw.println("    {");        // Note: The holders are now instantiated by the runtime and passed        // in as parameters.        // Call the real implementation        if (parms.returnParam == null) {            pw.print("        ");        } else {            pw.print("        " + Utils.getParameterTypeName(parms.returnParam)                    + " ret = ");        }        String call = "impl." + Utils.xmlNameToJava(operation.getName())                + "(";        boolean needComma = false;        for (int i = 0; i < parms.list.size(); ++i) {            if (needComma) {                call = call + ", ";            } else {                needComma = true;            }            Parameter p = (Parameter) parms.list.get(i);            call = call + Utils.xmlNameToJava(p.getName());        }        call = call + ")";        pw.println(call + ";");        if (parms.returnParam != null) {            pw.println("        return ret;");        }        pw.println("    }");        pw.println();    }    // writeSkeletonOperation}    // class JavaSkelWriter

⌨️ 快捷键说明

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