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

📄 service.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * 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.client;import org.apache.axis.AxisEngine;import org.apache.axis.EngineConfiguration;import org.apache.axis.configuration.EngineConfigurationFactoryFinder;import org.apache.axis.encoding.TypeMappingRegistryImpl;import org.apache.axis.utils.ClassUtils;import org.apache.axis.utils.Messages;import org.apache.axis.utils.WSDLUtils;import org.apache.axis.utils.XMLUtils;import org.apache.axis.wsdl.gen.Parser;import org.apache.axis.wsdl.symbolTable.BindingEntry;import org.apache.axis.wsdl.symbolTable.ServiceEntry;import org.apache.axis.wsdl.symbolTable.SymbolTable;import org.w3c.dom.Document;import javax.naming.Reference;import javax.naming.Referenceable;import javax.naming.StringRefAddr;import javax.wsdl.Binding;import javax.wsdl.Operation;import javax.wsdl.Port;import javax.wsdl.PortType;import javax.wsdl.extensions.soap.SOAPAddress;import javax.xml.namespace.QName;import javax.xml.rpc.ServiceException;import javax.xml.rpc.encoding.TypeMappingRegistry;import javax.xml.rpc.handler.HandlerRegistry;import java.io.InputStream;import java.io.Serializable;import java.lang.reflect.Constructor;import java.lang.reflect.Proxy;import java.net.MalformedURLException;import java.net.URL;import java.rmi.Remote;import java.util.HashMap;import java.util.Hashtable;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Vector;import java.util.WeakHashMap;/** * Axis' JAXRPC Dynamic Invoation Interface implementation of the Service * interface. * * The Service class should be used a the starting point for access * SOAP Web Services.  Typically, a Service will be created with a WSDL * document and along with a serviceName you can then ask for a Call * object that will allow you to invoke a Web Service. * * @author Doug Davis (dug@us.ibm.com) */public class Service implements javax.xml.rpc.Service, Serializable, Referenceable {    private transient AxisEngine engine = null;    private transient EngineConfiguration config = null;    private QName serviceName = null;    private String wsdlLocation = null;    private javax.wsdl.Service wsdlService = null;    private boolean maintainSession = false;    private HandlerRegistryImpl registry = new HandlerRegistryImpl();    private Parser wsdlParser = null;    private static Map cachedWSDL = new WeakHashMap();    private static boolean cachingWSDL = true;    // The last call object    protected Call _call = null;    /**     * A Hashtable mapping addresses (URLs) to Transports (objects)     */    private Hashtable transportImpls = new Hashtable();    protected javax.wsdl.Service getWSDLService() {        return (wsdlService);    }    public Parser getWSDLParser() {        return (wsdlParser);    }    protected AxisClient getAxisClient() {        return new AxisClient(getEngineConfiguration());    }    /**     * Constructs a new Service object - this assumes the caller will set     * the appropriate fields by hand rather than getting them from the     * WSDL.     */    public Service() {        engine = getAxisClient();    }    /**     * Constructs a new Service object - this assumes the caller will set     * the appropriate fields by hand rather than getting them from the     * WSDL.     */    public Service(QName serviceName) {        this.serviceName = serviceName;        engine = getAxisClient();    }    /**     * Constructs a Service using the supplied configuration and engine directly.     *     * @param engineConfiguration     * @param axisClient     */    public Service(EngineConfiguration engineConfiguration, AxisClient axisClient) {        this.config = engineConfiguration;        this.engine = axisClient;    }    /**     * Constructs a new Service object as above, but also passing in     * the EngineConfiguration which should be used to set up the     * AxisClient.     */    public Service(EngineConfiguration config) {        this.config = config;        engine = getAxisClient();    }    /**     * Constructs a new Service object for the service in the WSDL document     * pointed to by the wsdlDoc URL and serviceName parameters.     *     * @param wsdlDoc          URL of the WSDL document     * @param serviceName      Qualified name of the desired service     * @throws ServiceException If there's an error finding or parsing the WSDL     */    public Service(URL wsdlDoc, QName serviceName) throws ServiceException {        this.serviceName = serviceName;        engine = getAxisClient();        wsdlLocation = wsdlDoc.toString();        Parser parser = null;        if (cachingWSDL &&                (parser = (Parser) cachedWSDL.get(this.wsdlLocation.toString())) != null) {            initService(parser, serviceName);        } else {            initService(wsdlDoc.toString(), serviceName);        }    }    /**     * Constructs a new Service object for the service in the WSDL document     *     * @param parser          Parser for this service     * @param serviceName      Qualified name of the desired service     * @throws ServiceException If there's an error     */    public Service(Parser parser, QName serviceName) throws ServiceException {        this.serviceName = serviceName;        engine = getAxisClient();        initService(parser, serviceName);    }    /**     * Constructs a new Service object for the service in the WSDL document     * pointed to by the wsdlLocation and serviceName parameters.  This is     * just like the previous constructor but instead of URL the     * wsdlLocation parameter points to a file on the filesystem relative     * to the current directory.     *     * @param  wsdlLocation    Location of the WSDL relative to the current dir     * @param  serviceName     Qualified name of the desired service     * @throws ServiceException If there's an error finding or parsing the WSDL     */    public Service(String wsdlLocation, QName serviceName)            throws ServiceException {        this.serviceName = serviceName;        this.wsdlLocation = wsdlLocation;        engine = getAxisClient();        // Start by reading in the WSDL using Parser        Parser parser = null;        if (cachingWSDL &&                (parser = (Parser) cachedWSDL.get(wsdlLocation)) != null) {            initService(parser, serviceName);        } else {            initService(wsdlLocation, serviceName);        }    }    /**     * Constructs a new Service object for the service in the WSDL document     * in the wsdlInputStream and serviceName parameters.  This is     * just like the previous constructor but instead of reading the WSDL     * from a file (or from a URL) it is in the passed in InputStream.     *     * @param  wsdlInputStream InputStream containing the WSDL     * @param  serviceName     Qualified name of the desired service     * @throws ServiceException If there's an error finding or parsing the WSDL     */    public Service(InputStream wsdlInputStream, QName serviceName)            throws ServiceException {        engine = getAxisClient();        Document doc = null;        try {            doc = XMLUtils.newDocument(wsdlInputStream);        } catch (Exception exp) {            throw new ServiceException(                    Messages.getMessage("wsdlError00", "" + "", "\n" + exp));        }        initService(null, doc, serviceName);    }    /**     * Common code for building up the Service from a WSDL document     *     * @param url               URL for the WSDL document     * @param serviceName       Qualified name of the desired service     * @throws ServiceException  If there's an error finding or parsing the WSDL     */    private void initService(String url, QName serviceName)            throws ServiceException {        try {            // Start by reading in the WSDL using Parser            Parser parser = new Parser();            parser.run(url);            if (cachingWSDL && this.wsdlLocation != null)                cachedWSDL.put(url, parser);            initService(parser, serviceName);        } catch (Exception exp) {            throw new ServiceException(                    Messages.getMessage("wsdlError00", "" + "", "\n" + exp),                    exp);        }    }    /**     * Common code for building up the Service from a WSDL document     *     * @param context           Context URL     * @param doc               A DOM document containing WSDL     * @param serviceName       Qualified name of the desired service     * @throws ServiceException  If there's an error finding or parsing the WSDL     */    private void initService(String context, Document doc, QName serviceName)            throws ServiceException {        try {            // Start by reading in the WSDL using Parser            Parser parser = new Parser();            parser.run(context, doc);            initService(parser, serviceName);        } catch (Exception exp) {            throw new ServiceException(                    Messages.getMessage("wsdlError00", "" + "", "\n" + exp));        }    }    /**     *  Code for building up the Service from a Parser     *     * @param parser            Parser for this service     * @param serviceName       Qualified name of the desired service     * @throws ServiceException If there's an error finding or parsing the WSDL     */    private void initService(Parser parser, QName serviceName)            throws ServiceException {        try {            this.wsdlParser = parser;            ServiceEntry serviceEntry = parser.getSymbolTable().getServiceEntry(serviceName);            if (serviceEntry != null)                this.wsdlService = serviceEntry.getService();            if (this.wsdlService == null)                throw new ServiceException(                        Messages.getMessage("noService00", "" + serviceName));        } catch (Exception exp) {            throw new ServiceException(                    Messages.getMessage("wsdlError00", "" + "", "\n" + exp));        }    }    /**     * Return either an instance of a generated stub, if it can be     * found, or a dynamic proxy for the given proxy interface.

⌨️ 快捷键说明

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