📄 call.java
字号:
setOperationName( new QName( ns, opName ) ); } break ; } } } Service service = this.getService(); SymbolTable symbolTable = service.getWSDLParser().getSymbolTable(); BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName()); Parameters parameters = bEntry.getParameters(bop.getOperation()); // loop over paramters and set up in/out params for (int j = 0; j < parameters.list.size(); ++j) { Parameter p = (Parameter) parameters.list.get(j); // Get the QName representing the parameter type QName paramType = Utils.getXSIType(p); // checks whether p is an IN or OUT header // and adds it as a header parameter else // add it to the body ParameterMode mode = modes[p.getMode()]; if (p.isInHeader() || p.isOutHeader()) { this.addParameterAsHeader(p.getQName(), paramType, mode, mode); } else { this.addParameter(p.getQName(), paramType, mode); } } Map faultMap = bEntry.getFaults(); // Get the list of faults for this operation ArrayList faults = (ArrayList) faultMap.get(bop); // check for no faults if (faults == null) { return; } // For each fault, register its information for (Iterator faultIt = faults.iterator(); faultIt.hasNext();) { FaultInfo info = (FaultInfo) faultIt.next(); QName qname = info.getQName(); info.getMessage(); // if no parts in fault, skip it! if (qname == null) { continue; } QName xmlType = info.getXMLType(); Class clazz = getTypeMapping().getClassForQName(xmlType); if (clazz != null) { addFault(qname, clazz, xmlType, true); } else { //we cannot map from the info to a java class //In Axis1.1 and before this was silently swallowed. Now we log it log.debug(Messages.getMessage("clientNoTypemapping", xmlType.toString())); } } // set output type if (parameters.returnParam != null) { // Get the QName for the return Type QName returnType = Utils.getXSIType(parameters.returnParam); QName returnQName = parameters.returnParam.getQName(); // Get the javaType String javaType = null; if (parameters.returnParam.getMIMEInfo() != null) { javaType = "javax.activation.DataHandler"; } else { javaType = parameters.returnParam.getType().getName(); } if (javaType == null) { javaType = ""; } else { javaType = javaType + ".class"; } this.setReturnType(returnType); try { Class clazz = ClassUtils.forName(javaType); this.setReturnClass(clazz); } catch (ClassNotFoundException swallowedException) { //log that this lookup failed, log.debug(Messages.getMessage("clientNoReturnClass", javaType)); } this.setReturnQName(returnQName); } else { this.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID); } boolean hasMIME = Utils.hasMIME(bEntry, bop); Use use = bEntry.getInputBodyType(bop.getOperation()); setOperationUse(use); if (use == Use.LITERAL) { // Turn off encoding setEncodingStyle(null); // turn off XSI types setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); } if (hasMIME || use == Use.LITERAL) { // If it is literal, turn off multirefs. // // If there are any MIME types, turn off multirefs. // I don't know enough about the guts to know why // attachments don't work with multirefs, but they don't. setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); } Style style = Style.getStyle(opStyle, bEntry.getBindingStyle()); if (style == Style.DOCUMENT && symbolTable.isWrapped()) { style = Style.WRAPPED; } setOperationStyle(style); // Operation name if (style == Style.WRAPPED) { // We need to make sure the operation name, which is what we // wrap the elements in, matches the Qname of the parameter // element. Map partsMap = bop.getOperation().getInput().getMessage().getParts(); Part p = (Part)partsMap.values().iterator().next(); QName q = p.getElementName(); setOperationName(q); } else { QName elementQName = Utils.getOperationQName(bop, bEntry, symbolTable); if (elementQName != null) { setOperationName(elementQName); } } // Indicate that the parameters and return no longer // need to be specified with addParameter calls. parmAndRetReq = false; return; } /** * prefill as much info from the WSDL as it can. * Right now it's target URL, SOAPAction, Parameter types, * and return type of the Web Service. * * If wsdl is not present, this function set port name and operation name * and does not modify target endpoint address. * * Note: Not part of JAX-RPC specification. * * @param portName PortName in the WSDL doc to search for * @param opName Operation(method) that's going to be invoked */ public void setOperation(QName portName, String opName) { setOperation(portName, new QName(opName)); } /** * prefill as much info from the WSDL as it can. * Right now it's target URL, SOAPAction, Parameter types, * and return type of the Web Service. * * If wsdl is not present, this function set port name and operation name * and does not modify target endpoint address. * * Note: Not part of JAX-RPC specification. * * @param portName PortName in the WSDL doc to search for * @param opName Operation(method) that's going to be invoked */ public void setOperation(QName portName, QName opName) { if ( service == null ) throw new JAXRPCException( Messages.getMessage("noService04") ); // Make sure we're making a fresh start. this.setPortName( portName ); this.setOperationName( opName ); this.setReturnType( null ); this.removeAllParameters(); javax.wsdl.Service wsdlService = service.getWSDLService(); // Nothing to do is the WSDL is not already set. if(wsdlService == null) { return; } // we reinitialize target endpoint only if we have wsdl this.setTargetEndpointAddress( (URL) null ); Port port = wsdlService.getPort( portName.getLocalPart() ); if ( port == null ) { throw new JAXRPCException( Messages.getMessage("noPort00", "" + portName) ); } // Get the URL //////////////////////////////////////////////////////////////////// List list = port.getExtensibilityElements(); for ( int i = 0 ; list != null && i < list.size() ; i++ ) { Object obj = list.get(i); if ( obj instanceof SOAPAddress ) { try { SOAPAddress addr = (SOAPAddress) obj ; URL url = new URL(addr.getLocationURI()); this.setTargetEndpointAddress(url); } catch(Exception exp) { throw new JAXRPCException( Messages.getMessage("cantSetURI00", "" + exp) ); } } } setOperation(opName.getLocalPart()); } /** * Returns the fully qualified name of the port for this Call object * (if there is one). * * @return QName Fully qualified name of the port (or null if not set) */ public QName getPortName() { return( portName ); } // getPortName /** * Sets the port name of this Call object. This call will not set * any additional fields, nor will it do any checking to verify that * this port name is actually defined in the WSDL - for now anyway. * * @param portName Fully qualified name of the port */ public void setPortName(QName portName) { this.portName = portName; } // setPortName /** * Returns the fully qualified name of the port type for this Call object * (if there is one). * * @return QName Fully qualified name of the port type */ public QName getPortTypeName() { return portTypeName == null ? new QName("") : portTypeName; } /** * Sets the port type name of this Call object. This call will not set * any additional fields, nor will it do any checking to verify that * this port type is actually defined in the WSDL - for now anyway. * * @param portType Fully qualified name of the portType */ public void setPortTypeName(QName portType) { this.portTypeName = portType; } /** * Allow the user to set the default SOAP version. For SOAP 1.2, pass * SOAPConstants.SOAP12_CONSTANTS. * * @param soapConstants the SOAPConstants object representing the correct * version */ public void setSOAPVersion(SOAPConstants soapConstants) { msgContext.setSOAPConstants(soapConstants); } /** * Invokes a specific operation using a synchronous request-response interaction mode. The invoke method takes * as parameters the object values corresponding to these defined parameter types. Implementation of the invoke * method must check whether the passed parameter values correspond to the number, order and types of parameters * specified in the corresponding operation specification. * * @param operationName - Name of the operation to invoke * @param params - Parameters for this invocation * * @return the value returned from the other end. * * @throws java.rmi.RemoteException - if there is any error in the remote method invocation or if the Call * object is not configured properly. */ public Object invoke(QName operationName, Object[] params) throws java.rmi.RemoteException { QName origOpName = this.operationName; this.operationName = operationName; try { return this.invoke(params); } catch (AxisFault af) { this.operationName = origOpName; if(af.detail != null && af.detail instanceof RemoteException) { throw ((RemoteException)af.detail); } throw af; } catch (java.rmi.RemoteException re) { this.operationName = origOpName; throw re; } catch (RuntimeException re) { this.operationName = origOpName; throw re; } catch (Error e) { this.operationName = origOpName; throw e; } } // invoke /** * Invokes the operation associated with this Call object using the * passed in parameters as the arguments to the method. * * For Messaging (ie. non-RPC) the params argument should be an array * of SOAPBodyElements. <b>All</b> of them need to be SOAPBodyElements, * if any of them are not this method will default back to RPC. In the * Messaging case the return value will be a vector of SOAPBodyElements. * * @param params Array of parameters to invoke the Web Service with * @return Object Return value of the operation/method - or null * @throws java.rmi.RemoteException if there's an error */ public Object invoke(Object[] params) throws java.rmi.RemoteException { long t0=0, t1=0; if( tlog.isDebugEnabled() ) { t0=System.currentTimeMillis(); } /* First see if we're dealing with Messaging instead of RPC. */ /* If ALL of the params are SOAPBodyElements then we're doing */ /* Messaging, otherwise just fall through to normal RPC processing. */ /********************************************************************/ SOAPEnvelope env = null ; int i ; for ( i = 0 ; params != null && i < params.length ; i++ ) if ( !(params[i] instanceof SOAPBodyElement) ) break ; if ( params != null && params.length > 0 && i == params.length ) { /* ok, we're doing Messaging, so build up the message */ /******************************************************/ isMsg = true ; env = new SOAPEnvelope(msgContext.getSOAPConstants(), msgContext.getSchemaVersion()); for (i = 0; i < params.length; i++) { env.addBodyElement((SOAPBodyElement) params[i]); } Message msg = new Message( en
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -