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

📄 emitter.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                 * If it's a non-standard type, make sure it shows up in                  * our WSDL                  */                 if (standardTypes.getSerializer(mappedType) == null) {                     types.writeTypeForPart(mappedType, name);                 }             }                        // Don't bother checking for subtypes, since we already wrote            // all the possibilities.            types.mappedTypes = null;        }                return types;    }        /**     * Create a documentation element     *       * @param documentation     * @return     */    protected Element createDocumentationElement(String documentation) {        Element element = docHolder.createElementNS(Constants.NS_URI_WSDL11, "documentation");        element.setPrefix(Constants.NS_PREFIX_WSDL);        Text textNode =                docHolder.createTextNode(documentation);        element.appendChild(textNode);        return element;    }        /**     * Create the definition header information.     *      * @param def <code>Definition</code>     * @param tns target namespace     */    protected void writeDefinitions(Definition def, String tns) {        def.setTargetNamespace(tns);        def.addNamespace("intf", intfNS);        def.addNamespace("impl", implNS);        def.addNamespace(Constants.NS_PREFIX_WSDL_SOAP,                Constants.URI_WSDL11_SOAP);        namespaces.putPrefix(Constants.URI_WSDL11_SOAP,                Constants.NS_PREFIX_WSDL_SOAP);        def.addNamespace(Constants.NS_PREFIX_WSDL, Constants.NS_URI_WSDL11);        namespaces.putPrefix(Constants.NS_URI_WSDL11, Constants.NS_PREFIX_WSDL);        if (use == Use.ENCODED) {            def.addNamespace(Constants.NS_PREFIX_SOAP_ENC,                    Constants.URI_DEFAULT_SOAP_ENC);            namespaces.putPrefix(Constants.URI_DEFAULT_SOAP_ENC,                    Constants.NS_PREFIX_SOAP_ENC);        }        def.addNamespace(Constants.NS_PREFIX_SCHEMA_XSD,                Constants.URI_DEFAULT_SCHEMA_XSD);        namespaces.putPrefix(Constants.URI_DEFAULT_SCHEMA_XSD,                Constants.NS_PREFIX_SCHEMA_XSD);        def.addNamespace(Constants.NS_PREFIX_XMLSOAP, Constants.NS_URI_XMLSOAP);        namespaces.putPrefix(Constants.NS_URI_XMLSOAP,                Constants.NS_PREFIX_XMLSOAP);    }    /**     * Create and add an import     *      * @param def <code>Definition</code>     * @param tns target namespace     * @param loc target location     */    protected void writeImport(Definition def, String tns, String loc) {        Import imp = def.createImport();        imp.setNamespaceURI(tns);        if ((loc != null) && !loc.equals("")) {            imp.setLocationURI(loc);        }        def.addImport(imp);    }    /**     * Create the binding.     *      * @param def <code>Definition</code>     * @param add true if binding should be added to the def     * @return      */    protected Binding writeBinding(Definition def, boolean add) {        QName bindingQName = new QName(intfNS, getBindingName());        // If a binding already exists, don't replace it.        Binding binding = def.getBinding(bindingQName);        if (binding != null) {            return binding;        }        // Create a binding        binding = def.createBinding();        binding.setUndefined(false);        binding.setQName(bindingQName);        SOAPBinding soapBinding = new SOAPBindingImpl();        String styleStr = (style == Style.RPC)                ? "rpc"                : "document";        soapBinding.setStyle(styleStr);        soapBinding.setTransportURI(Constants.URI_SOAP11_HTTP);        binding.addExtensibilityElement(soapBinding);        if (add) {            def.addBinding(binding);        }        return binding;    }    /** Field docHolder */    Document docHolder;    /**     * Method createDocumentFragment     */    private void createDocumentFragment() {        try {            this.docHolder = XMLUtils.newDocument();        } catch (ParserConfigurationException e) {            // This should not occur            throw new InternalException(e);        }    }    /**     * Create the service.     *      * @param def          * @param binding      */    protected void writeService(Definition def, Binding binding) {        QName serviceElementQName = new QName(implNS, getServiceElementName());        // Locate an existing service, or get a new service        Service service = def.getService(serviceElementQName);        if (service == null) {            service = def.createService();            service.setQName(serviceElementQName);            def.addService(service);        }        if (description != null) {            service.setDocumentationElement(                    createDocumentationElement(description));        } else if (serviceDesc.getDocumentation() != null) {            service.setDocumentationElement(                    createDocumentationElement(                            serviceDesc.getDocumentation()));        }        // Add the port        Port port = def.createPort();        port.setBinding(binding);        // Probably should use the end of the location Url        port.setName(getServicePortName());        SOAPAddress addr = new SOAPAddressImpl();        addr.setLocationURI(locationUrl);        port.addExtensibilityElement(addr);        service.addPort(port);    }    /**     * Create a PortType     *      * @param def          * @param binding      * @throws WSDLException      * @throws AxisFault          */    protected void writePortType(Definition def, Binding binding)            throws WSDLException, AxisFault {        QName portTypeQName = new QName(intfNS, getPortTypeName());        // Get or create a portType        PortType portType = def.getPortType(portTypeQName);        boolean newPortType = false;        if (portType == null) {            portType = def.createPortType();            portType.setUndefined(false);            portType.setQName(portTypeQName);            newPortType = true;        } else if (binding.getBindingOperations().size() > 0) {            // If both portType and binding already exist,            // no additional processing is needed.            return;        }        // Add the port and binding operations.        ArrayList operations = serviceDesc.getOperations();        for (Iterator i = operations.iterator(); i.hasNext();) {            OperationDesc thisOper = (OperationDesc) i.next();            BindingOperation bindingOper = writeOperation(def, binding,                    thisOper);            Operation oper = bindingOper.getOperation();            OperationDesc messageOper = thisOper;            // add the documentation to oper            if (messageOper.getDocumentation() != null) {                oper.setDocumentationElement(                        createDocumentationElement(                                messageOper.getDocumentation()));            }            if (serviceDesc2 != null) {                // If a serviceDesc containing an impl class is provided,                // try and locate the corresponding operation                // (same name, same parm types and modes).  If a                // corresponding operation is found, it is sent                // to the writeMessages method so that its parameter                // names will be used in the wsdl file.                OperationDesc[] operArray =                        serviceDesc2.getOperationsByName(thisOper.getName());                boolean found = false;                if (operArray != null) {                    for (int j = 0; (j < operArray.length) && !found; j++) {                        OperationDesc tryOper = operArray[j];                        if (tryOper.getParameters().size()                                == thisOper.getParameters().size()) {                            boolean parmsMatch = true;                            for (int k =                                    0; (k < thisOper.getParameters().size())                                    && parmsMatch; k++) {                                if ((tryOper.getParameter(                                        k).getMode() != thisOper.getParameter(                                                k).getMode())                                        || (!tryOper.getParameter(                                                k).getJavaType().equals(                                                        thisOper.getParameter(                                                                k).getJavaType()))) {                                    parmsMatch = false;                                }                            }                            if (parmsMatch) {                                messageOper = tryOper;                                found = true;                            }                        }                    }                }            }            writeMessages(def, oper, messageOper, bindingOper);            if (newPortType) {                portType.addOperation(oper);            }        }        if (newPortType) {            def.addPortType(portType);        }        binding.setPortType(portType);    }    /**     * Create a Message     *      * @param def         Definition, the WSDL definition     * @param oper        Operation, the wsdl operation     * @param desc        OperationDesc, the Operation Description     * @param bindingOper BindingOperation, corresponding Binding Operation     * @throws WSDLException      * @throws AxisFault          */    protected void writeMessages(Definition def,                                 Operation oper,                                 OperationDesc desc,                                 BindingOperation bindingOper)            throws WSDLException, AxisFault {        Input input = def.createInput();        Message msg = writeRequestMessage(def, desc, bindingOper);        input.setMessage(msg);        // Give the input element a name that matches the        // message.  This is necessary for overloading.        // The msg QName is unique.        String name = msg.getQName().getLocalPart();        input.setName(name);        bindingOper.getBindingInput().setName(name);        oper.setInput(input);        def.addMessage(msg);                if (OperationType.REQUEST_RESPONSE.equals(desc.getMep())) {            msg = writeResponseMessage(def, desc, bindingOper);                        Output output = def.createOutput();                        output.setMessage(msg);                        // Give the output element a name that matches the            // message.  This is necessary for overloading.            // The message QName is unique.            name = msg.getQName().getLocalPart();                        output.setName(name);            bindingOper.getBindingOutput().setName(name);            oper.setOutput(output);            def.addMessage(msg);        }                ArrayList exceptions = desc.getFaults();        for (int i = 0; (exceptions != null) && (i < exceptions.size()); i++) {            FaultDesc faultDesc = (FaultDesc) exceptions.get(i);            msg = writeFaultMessage(def, faultDesc);            // Add the fault to the portType            Fault fault = def.createFault();            fault.setMessage(msg);            fault.setName(faultDesc.getName());            oper.addFault(fault);            // Add the fault to the binding            BindingFault bFault = def.createBindingFault();            bFault.setName(faultDesc.getName());            SOAPFault soapFault = writeSOAPFault(faultDesc);            bFault.addExtensibilityElement(soapFault);            bindingOper.addBindingFault(bFault);            // Add the fault message            if (def.getMessage(msg.getQName()) == null) {                def.addMessage(msg);            }        }        // Set the parameter ordering using the parameter names        ArrayList parameters = desc.getParameters();        Vector names = new Vector();        for (int i = 0; i < parameters.size(); i++) {            ParameterDesc param = (ParameterDesc) parameters.get(i);            names.add(param.getName());        }        if (names.size() > 0) {            if (style == Style.WRAPPED) {                names.clear();            } else {                oper.setParameterOrdering(names);            }        }    }    /**     * Create a Operation     *      * @param def          * @param binding      * @param desc         * @return      */

⌨️ 快捷键说明

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