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

📄 emitter.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * Copyright 2001-2004 The Apache Software Foundation. *  * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *  *      http://www.apache.org/licenses/LICENSE-2.0 *  * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.axis.wsdl.fromJava;import com.ibm.wsdl.extensions.soap.SOAPAddressImpl;import com.ibm.wsdl.extensions.soap.SOAPBindingImpl;import com.ibm.wsdl.extensions.soap.SOAPBodyImpl;import com.ibm.wsdl.extensions.soap.SOAPHeaderImpl;import com.ibm.wsdl.extensions.soap.SOAPOperationImpl;import org.apache.axis.AxisFault;import org.apache.axis.Constants;import org.apache.axis.InternalException;import org.apache.axis.Version;import org.apache.axis.components.logger.LogFactory;import org.apache.axis.constants.Style;import org.apache.axis.constants.Use;import org.apache.axis.description.FaultDesc;import org.apache.axis.description.JavaServiceDesc;import org.apache.axis.description.OperationDesc;import org.apache.axis.description.ParameterDesc;import org.apache.axis.description.ServiceDesc;import org.apache.axis.encoding.TypeMapping;import org.apache.axis.encoding.TypeMappingRegistry;import org.apache.axis.encoding.TypeMappingRegistryImpl;import org.apache.axis.utils.ClassUtils;import org.apache.axis.utils.JavaUtils;import org.apache.axis.utils.Messages;import org.apache.axis.utils.XMLUtils;import org.apache.axis.wsdl.symbolTable.SymbolTable;import org.apache.commons.logging.Log;import org.w3c.dom.Comment;import org.w3c.dom.Document;import org.w3c.dom.Element;import org.w3c.dom.Text;import org.xml.sax.SAXException;import javax.wsdl.Binding;import javax.wsdl.BindingFault;import javax.wsdl.BindingInput;import javax.wsdl.BindingOperation;import javax.wsdl.BindingOutput;import javax.wsdl.Definition;import javax.wsdl.Fault;import javax.wsdl.Import;import javax.wsdl.Input;import javax.wsdl.Message;import javax.wsdl.Operation;import javax.wsdl.OperationType;import javax.wsdl.Output;import javax.wsdl.Part;import javax.wsdl.Port;import javax.wsdl.PortType;import javax.wsdl.Service;import javax.wsdl.WSDLException;import javax.wsdl.extensions.ExtensibilityElement;import javax.wsdl.extensions.soap.SOAPAddress;import javax.wsdl.extensions.soap.SOAPBinding;import javax.wsdl.extensions.soap.SOAPBody;import javax.wsdl.extensions.soap.SOAPFault;import javax.wsdl.extensions.soap.SOAPHeader;import javax.wsdl.extensions.soap.SOAPOperation;import javax.wsdl.factory.WSDLFactory;import javax.xml.namespace.QName;import javax.xml.parsers.ParserConfigurationException;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.StringWriter;import java.util.ArrayList;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.StringTokenizer;import java.util.Vector;/** * This class emits WSDL from Java classes.  It is used by the ?WSDL * Axis browser function and Java2WSDL commandline utility. * See Java2WSDL and Java2WSDLFactory for more information. *  * @author Glen Daniels (gdaniels@apache.org) * @author Rich Scheuerle (scheu@us.ibm.com) */public class Emitter {    /** Field log */    protected static Log log = LogFactory.getLog(Emitter.class.getName());    // Generated WSDL Modes    /** Field MODE_ALL */    public static final int MODE_ALL = 0;    /** Field MODE_INTERFACE */    public static final int MODE_INTERFACE = 1;    /** Field MODE_IMPLEMENTATION */    public static final int MODE_IMPLEMENTATION = 2;    /** Field cls */    private Class cls;    /** Field extraClasses */    private Class[] extraClasses;               // Extra classes to emit WSDL for    /** Field implCls */    private Class implCls;                      // Optional implementation class    /** Field allowedMethods */    private Vector allowedMethods = null;       // Names of methods to consider    /** Field disallowedMethods */    private Vector disallowedMethods = null;    // Names of methods to exclude    /** Field stopClasses */    private ArrayList stopClasses =            new ArrayList();                        // class names which halt inheritace searches    /** Field useInheritedMethods */    private boolean useInheritedMethods = false;    /** Field intfNS */    private String intfNS;    /** Field implNS */    private String implNS;    /** Field inputSchema */    private String inputSchema;    /** Field inputWSDL */    private String inputWSDL;    /** Field locationUrl */    private String locationUrl;    /** Field importUrl */    private String importUrl;    /** Field servicePortName */    private String servicePortName;    /** Field serviceElementName */    private String serviceElementName;    /** Field targetService */    private String targetService = null;    /** Field description */    private String description;    /** Field style */    private Style style = Style.RPC;    /** Field use */    private Use use = null;                     // Default depends on style setting    /** Field tm */    private TypeMapping tm = null;              // Registered type mapping    /** Field tmr */    private TypeMappingRegistry tmr = new TypeMappingRegistryImpl();    /** Field namespaces */    private Namespaces namespaces;    /** Field exceptionMsg */    private Map exceptionMsg = null;    /** Global element names already in use */    private Map usedElementNames;    /** Field encodingList */    private ArrayList encodingList;    /** Field types */    protected Types types;    /** Field clsName */    private String clsName;    /** Field portTypeName */    private String portTypeName;    /** Field bindingName */    private String bindingName;    /** Field serviceDesc */    private ServiceDesc serviceDesc;    /** Field serviceDesc2 */    private JavaServiceDesc serviceDesc2;    /** Field soapAction */    private String soapAction = "DEFAULT";        /** Should we emit all mapped types in every WSDL? */    private boolean emitAllTypes = false;    /** Version string to put at top of WSDL */    private String versionMessage = null;        /** The mapping of generated type qname to its corresponding java type. For use with java<-->wsdl roundtripping */    private HashMap qName2ClassMap;    // Style Modes    /** DEPRECATED - Indicates style=rpc use=encoded */    public static final int MODE_RPC = 0;    /** DEPRECATED - Indicates style=document use=literal */    public static final int MODE_DOCUMENT = 1;    /** DEPRECATED - Indicates style=wrapped use=literal */    public static final int MODE_DOC_WRAPPED = 2;    /**     * Construct Emitter.     * Set the contextual information using set* methods     * Invoke emit to emit the code     */    public Emitter() {        createDocumentFragment();        namespaces = new Namespaces();        exceptionMsg = new HashMap();        usedElementNames = new HashMap();        qName2ClassMap = new HashMap();    }    /**     * Generates WSDL documents for a given <code>Class</code>     *      * @param filename1 interface WSDL     * @param filename2 implementation WSDL     * @throws IOException                       * @throws WSDLException                     * @throws SAXException                      * @throws ParserConfigurationException      */    public void emit(String filename1, String filename2)            throws IOException, WSDLException, SAXException,            ParserConfigurationException {        // Get interface and implementation defs        Definition intf = getIntfWSDL();        Definition impl = getImplWSDL();        // Supply reasonable file names if not supplied        if (filename1 == null) {            filename1 = getServicePortName() + "_interface.wsdl";        }        if (filename2 == null) {            filename2 = getServicePortName() + "_implementation.wsdl";        }        for (int i = 0; (extraClasses != null) && (i < extraClasses.length);             i++) {            types.writeTypeForPart(extraClasses[i], null);        }        // types.updateNamespaces();        // Write out the interface def        Document doc =                WSDLFactory.newInstance().newWSDLWriter().getDocument(intf);        types.insertTypesFragment(doc);        prettyDocumentToFile(doc, filename1);        // Write out the implementation def        doc = WSDLFactory.newInstance().newWSDLWriter().getDocument(impl);        prettyDocumentToFile(doc, filename2);    }    /**     * Generates a complete WSDL document for a given <code>Class</code>     *      * @param filename WSDL     * @throws IOException                       * @throws WSDLException                     * @throws SAXException                      * @throws ParserConfigurationException      */    public void emit(String filename)            throws IOException, WSDLException, SAXException,            ParserConfigurationException {        emit(filename, MODE_ALL);    }    /**     * Generates a WSDL document for a given <code>Class</code>.     * The WSDL generated is controlled by the mode parameter     * mode 0: All     * mode 1: Interface     * mode 2: Implementation     *      * @param mode generation mode - all, interface, implementation     * @return Document     * @throws IOException                       * @throws WSDLException                     * @throws SAXException                      * @throws ParserConfigurationException      */    public Document emit(int mode)            throws IOException, WSDLException, SAXException,            ParserConfigurationException {        Document doc;        Definition def;        switch (mode) {            default:            case MODE_ALL:                def = getWSDL();                for (int i = 0;                     (extraClasses != null) && (i < extraClasses.length);                     i++) {                    types.writeTypeForPart(extraClasses[i], null);                }                // types.updateNamespaces();                doc = WSDLFactory.newInstance().newWSDLWriter().getDocument(                        def);                types.insertTypesFragment(doc);                break;            case MODE_INTERFACE:                def = getIntfWSDL();                for (int i = 0;                     (extraClasses != null) && (i < extraClasses.length);                     i++) {                    types.writeTypeForPart(extraClasses[i], null);                }                // types.updateNamespaces();                doc = WSDLFactory.newInstance().newWSDLWriter().getDocument(                        def);                types.insertTypesFragment(doc);                break;            case MODE_IMPLEMENTATION:                def = getImplWSDL();                doc = WSDLFactory.newInstance().newWSDLWriter().getDocument(                        def);                break;        }        // Add Axis version info as comment to beginnning of generated WSDL        if (versionMessage == null) {            versionMessage = Messages.getMessage(                    "wsdlCreated00",                    XMLUtils.xmlEncodeString(Version.getVersion()));        }        // If version is empty string, don't emit one        if (versionMessage != null && versionMessage.length() > 0) {            Comment wsdlVersion = doc.createComment(versionMessage);            doc.getDocumentElement().insertBefore(                    wsdlVersion, doc.getDocumentElement().getFirstChild());        }        // Return the document        return doc;    }    /**     * Generates a String containing the WSDL for a given <code>Class</code>.     * The WSDL generated is controlled by the mode parameter     * mode 0: All     * mode 1: Interface     * mode 2: Implementation     *      * @param mode generation mode - all, interface, implementation     * @return String     * @throws IOException                       * @throws WSDLException                     * @throws SAXException                      * @throws ParserConfigurationException 

⌨️ 快捷键说明

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