📄 call.java
字号:
/* * 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.AxisFault;import org.apache.axis.AxisProperties;import org.apache.axis.Constants;import org.apache.axis.Handler;import org.apache.axis.InternalException;import org.apache.axis.Message;import org.apache.axis.MessageContext;import org.apache.axis.AxisEngine;import org.apache.axis.SOAPPart;import org.apache.axis.attachments.Attachments;import org.apache.axis.components.logger.LogFactory;import org.apache.axis.description.FaultDesc;import org.apache.axis.description.OperationDesc;import org.apache.axis.description.ParameterDesc;import org.apache.axis.encoding.DeserializerFactory;import org.apache.axis.encoding.SerializationContext;import org.apache.axis.encoding.SerializerFactory;import org.apache.axis.encoding.TypeMapping;import org.apache.axis.encoding.TypeMappingRegistry;import org.apache.axis.encoding.XMLType;import org.apache.axis.encoding.ser.BaseDeserializerFactory;import org.apache.axis.encoding.ser.BaseSerializerFactory;import org.apache.axis.constants.Style;import org.apache.axis.constants.Use;import org.apache.axis.handlers.soap.SOAPService;import org.apache.axis.message.RPCElement;import org.apache.axis.message.RPCHeaderParam;import org.apache.axis.message.RPCParam;import org.apache.axis.message.SOAPBodyElement;import org.apache.axis.message.SOAPEnvelope;import org.apache.axis.message.SOAPFault;import org.apache.axis.message.SOAPHeaderElement;import org.apache.axis.soap.SOAPConstants;import org.apache.axis.transport.http.HTTPTransport;import org.apache.axis.utils.ClassUtils;import org.apache.axis.utils.JavaUtils;import org.apache.axis.utils.Messages;import org.apache.axis.utils.LockableHashtable;import org.apache.axis.wsdl.symbolTable.BindingEntry;import org.apache.axis.wsdl.symbolTable.Parameter;import org.apache.axis.wsdl.symbolTable.Parameters;import org.apache.axis.wsdl.symbolTable.SymbolTable;import org.apache.axis.wsdl.symbolTable.FaultInfo;import org.apache.axis.wsdl.toJava.Utils;import org.apache.commons.logging.Log;import javax.wsdl.Binding;import javax.wsdl.BindingInput;import javax.wsdl.BindingOperation;import javax.wsdl.Operation;import javax.wsdl.extensions.mime.MIMEPart;import javax.wsdl.extensions.mime.MIMEMultipartRelated;import javax.wsdl.Part;import javax.wsdl.Port;import javax.wsdl.PortType;import javax.wsdl.extensions.soap.SOAPAddress;import javax.wsdl.extensions.soap.SOAPBody;import javax.wsdl.extensions.soap.SOAPOperation;import javax.xml.namespace.QName;import javax.xml.rpc.JAXRPCException;import javax.xml.rpc.ParameterMode;import javax.xml.soap.SOAPException;import javax.xml.soap.SOAPMessage;import java.io.StringWriter;import java.net.MalformedURLException;import java.net.URL;import java.util.ArrayList;import java.util.HashMap;import java.util.Hashtable;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.StringTokenizer;import java.util.Vector;import java.rmi.RemoteException;/** * Axis' JAXRPC Dynamic Invocation Interface implementation of the Call * interface. This class should be used to actually invoke the Web Service. * It can be prefilled by a WSDL document (on the constructor to the Service * object) or you can fill in the data yourself. * <pre> * Standard properties defined by in JAX-RPC's javax..xml.rpc.Call interface: * USERNAME_PROPERTY - User name for authentication * PASSWORD_PROPERTY - Password for authentication * SESSION_PROPERTY - Participate in a session with the endpoint? * OPERATION_STYLE_PROPERTY - "rpc" or "document" * SOAPACTION_USE_PROPERTY - Should SOAPAction be used? * SOAPACTION_URI_PROPERTY - If SOAPAction is used, this is that action * ENCODING_STYLE_PROPERTY - Default is SOAP 1.1: "http://schemas.xmlsoap.org/soap/encoding/" * * AXIS properties: * SEND_TYPE_ATTR - Should we send the XSI type attributes (true/false) * TIMEOUT - Timeout used by transport sender in milliseconds * TRANSPORT_NAME - Name of transport handler to use * ATTACHMENT_ENCAPSULATION_FORMAT- Send attachments as MIME the default, or DIME. * CHARACTER_SET_ENCODING - Character set encoding to use for request * </pre> * * @author Doug Davis (dug@us.ibm.com) * @author Steve Loughran */public class Call implements javax.xml.rpc.Call { protected static Log log = LogFactory.getLog(Call.class.getName()); private static Log tlog = LogFactory.getLog(Constants.TIME_LOG_CATEGORY); // The enterprise category is for stuff that an enterprise product might // want to track, but in a simple environment (like the AXIS build) would // be nothing more than a nuisance. protected static Log entLog = LogFactory.getLog(Constants.ENTERPRISE_LOG_CATEGORY); private boolean parmAndRetReq = true ; private Service service = null ; private QName portName = null; private QName portTypeName = null; private QName operationName = null ; private MessageContext msgContext = null ; // Collection of properties to store and put in MessageContext at // invoke() time. Known ones are stored in actual variables for // efficiency/type-consistency. Unknown ones are in myProperties. private LockableHashtable myProperties = new LockableHashtable(); private String username = null; private String password = null; private boolean maintainSession = false; private boolean useSOAPAction = false; private String SOAPActionURI = null; private Integer timeout = null; private boolean useStreaming = false; /** Metadata for the operation associated with this Call */ private OperationDesc operation = null; /** This will be true if an OperationDesc is handed to us whole */ private boolean operationSetManually = false; // Is this a one-way call? private boolean invokeOneWay = false; private boolean isMsg = false; // Our Transport, if any private Transport transport = null ; private String transportName = null ; // A couple places to store output parameters. // As a HashMap, retrievable via QName (for getOutputParams). private HashMap outParams = null; // As a list, retrievable by index (for getOutputValues). private ArrayList outParamsList = null; // A place to store any client-specified headers private Vector myHeaders = null; public static final String SEND_TYPE_ATTR = AxisEngine.PROP_SEND_XSI; /** * This is the name of a property to set the transport of the message * * @see #setProperty */ public static final String TRANSPORT_NAME = "transport_name" ; /** * This is the character set encoding to use for the message * * @see #setProperty */ public static final String CHARACTER_SET_ENCODING = SOAPMessage.CHARACTER_SET_ENCODING; /** * This is not the name of a property that can be set with * setProperty, despite its name. */ public static final String TRANSPORT_PROPERTY= "java.protocol.handler.pkgs"; /** * this is a property set in the message context when the invocation * process begins, for the benefit of handlers */ public static final String WSDL_SERVICE = "wsdl.service"; /** * this is a property set in the message context when the invocation * process begins, for the benefit of handlers */ public static final String WSDL_PORT_NAME = "wsdl.portName"; /** * @deprecated use WSDL_SERVICE instead. */ public static final String JAXRPC_SERVICE = WSDL_SERVICE; /** * @deprecated use WSDL_PORT_NAME instead. */ public static final String JAXRPC_PORTTYPE_NAME = WSDL_PORT_NAME; /** * If this property is true, the code will throw a fault if there is no * response message from the server. Otherwise, the * invoke method will return a null. */ public static final String FAULT_ON_NO_RESPONSE = "call.FaultOnNoResponse"; /** * If this property is true, code will enforce must understand check on both * the request and the response paths. */ public static final String CHECK_MUST_UNDERSTAND = "call.CheckMustUnderstand"; /** * Property for setting attachment format. * Can be set to either DIME or MIME (default) * @see #setProperty * @see #ATTACHMENT_ENCAPSULATION_FORMAT_DIME * @see #ATTACHMENT_ENCAPSULATION_FORMAT_MIME * @see #ATTACHMENT_ENCAPSULATION_FORMAT_MTOM */ public static final String ATTACHMENT_ENCAPSULATION_FORMAT= "attachment_encapsulation_format"; /** * Property value for setting attachment format as MIME. */ public static final String ATTACHMENT_ENCAPSULATION_FORMAT_MIME= "axis.attachment.style.mime"; /** * Property value for setting attachment format as DIME. */ public static final String ATTACHMENT_ENCAPSULATION_FORMAT_DIME= "axis.attachment.style.dime"; /** * Property value for setting attachment format as DIME. */ public static final String ATTACHMENT_ENCAPSULATION_FORMAT_MTOM= "axis.attachment.style.mtom"; /** * Timeout property: should be accompanies by an integer * @see #setProperty */ public static final String CONNECTION_TIMEOUT_PROPERTY = "axis.connection.timeout"; /** * Streaming property: should be accompanied by an boolean * (i.e. NO high-fidelity recording, deserialize on the fly) * @see #setProperty */ public static final String STREAMING_PROPERTY = "axis.streaming"; /** * Internal property to indicate a one way call. * That will disable processing of response handlers. */ protected static final String ONE_WAY = "axis.one.way"; /** * A Hashtable mapping protocols (Strings) to Transports (classes) */ private static Hashtable transports = new Hashtable(); static ParameterMode [] modes = new ParameterMode [] { null, ParameterMode.IN, ParameterMode.OUT, ParameterMode.INOUT }; /** This is true when someone has called setEncodingStyle() */ private boolean encodingStyleExplicitlySet = false; /** This is true when someone has called setOperationUse() */ private boolean useExplicitlySet = false; /** * the name of a SOAP service that the call is bound to */ private SOAPService myService = null; /** * these are our attachments */ protected java.util.Vector attachmentParts = new java.util.Vector(); /** This is false when invoke() is called. */ private boolean isNeverInvoked = true; static { initialize(); } /************************************************************************/ /* Start of core JAX-RPC stuff */ /************************************************************************/ /** * Default constructor - not much else to say. * * @param service the <code>Service</code> this <code>Call</code> will * work with */ public Call(Service service) { this.service = service ; AxisEngine engine = service.getEngine(); msgContext = new MessageContext( engine ); myProperties.setParent(engine.getOptions()); maintainSession = service.getMaintainSession(); } /** * Build a call from a URL string. * * This is handy so that you don't have to manually call Call.initialize() * in order to register custom transports. In other words, whereas doing * a new URL("local:...") would fail, new Call("local:...") works because * we do the initialization of our own and any configured custom protocols. * * @param url the target endpoint URL * @exception MalformedURLException */ public Call(String url) throws MalformedURLException { this(new Service()); setTargetEndpointAddress(new URL(url)); } /** * Build a call from a URL. * * @param url the target endpoint URL */ public Call(URL url) { this(new Service()); setTargetEndpointAddress(url); } ////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -