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

📄 rpcprovider.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        /** If this is a one-way operation, there is nothing more to do.         */        if (OperationType.ONE_WAY.equals(operation.getMep()))            return;        RPCElement resBody = createResponseBody(body, msgContext, operation, serviceDesc, objRes, resEnv, outs);        resEnv.addBodyElement(resBody);    }    protected RPCElement getBody(SOAPEnvelope reqEnv, MessageContext msgContext) throws Exception {        SOAPService service = msgContext.getService();        ServiceDesc serviceDesc = service.getServiceDescription();        OperationDesc operation = msgContext.getOperation();        Vector bodies = reqEnv.getBodyElements();        if (log.isDebugEnabled()) {            log.debug(Messages.getMessage("bodyElems00", "" + bodies.size()));            if(bodies.size()>0){                log.debug(Messages.getMessage("bodyIs00", "" + bodies.get(0)));            }        }        RPCElement body = null;        // Find the first "root" body element, which is the RPC call.        for (int bNum = 0; body == null && bNum < bodies.size(); bNum++) {            // If this is a regular old SOAPBodyElement, and it's a root,            // we're probably a non-wrapped doc/lit service.  In this case,            // we deserialize the element, and create an RPCElement "wrapper"            // around it which points to the correct method.            // FIXME : There should be a cleaner way to do this...            if (!(bodies.get(bNum) instanceof RPCElement)) {                SOAPBodyElement bodyEl = (SOAPBodyElement) bodies.get(bNum);                // igors: better check if bodyEl.getID() != null                // to make sure this loop does not step on SOAP-ENC objects                // that follow the parameters! FIXME?                if (bodyEl.isRoot() && operation != null && bodyEl.getID() == null) {                    ParameterDesc param = operation.getParameter(bNum);                    // at least do not step on non-existent parameters!                    if (param != null) {                        Object val = bodyEl.getValueAsType(param.getTypeQName());                        body = new RPCElement("",                                              operation.getName(),                                              new Object[]{val});                    }                }            } else {                body = (RPCElement) bodies.get(bNum);            }        }        // special case code for a document style operation with no        // arguments (which is a strange thing to have, but whatever)        if (body == null) {            // throw an error if this isn't a document style service            if (!(serviceDesc.getStyle().equals(Style.DOCUMENT))) {                throw new Exception(Messages.getMessage("noBody00"));            }            // look for a method in the service that has no arguments,            // use the first one we find.            ArrayList ops = serviceDesc.getOperations();            for (Iterator iterator = ops.iterator(); iterator.hasNext();) {                OperationDesc desc = (OperationDesc) iterator.next();                if (desc.getNumInParams() == 0) {                    // found one with no parameters, use it                    msgContext.setOperation(desc);                    // create an empty element                    body = new RPCElement(desc.getName());                    // stop looking                    break;                }            }            // If we still didn't find anything, report no body error.            if (body == null) {                throw new Exception(Messages.getMessage("noBody00"));            }        }        return body;    }    protected OperationDesc getOperationDesc(MessageContext msgContext, RPCElement body) throws SAXException, AxisFault {        SOAPService service = msgContext.getService();        ServiceDesc serviceDesc = service.getServiceDescription();        String methodName = body.getMethodName();        // FIXME (there should be a cleaner way to do this)        OperationDesc operation = msgContext.getOperation();        if (operation == null) {            QName qname = new QName(body.getNamespaceURI(),                    body.getName());            operation = serviceDesc.getOperationByElementQName(qname);        if (operation == null) {            SOAPConstants soapConstants = msgContext == null ?                    SOAPConstants.SOAP11_CONSTANTS :                    msgContext.getSOAPConstants();            if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) {                AxisFault fault =                        new AxisFault(Constants.FAULT_SOAP12_SENDER,                                      Messages.getMessage("noSuchOperation",                                                          methodName),                                      null,                                      null);                fault.addFaultSubCode(Constants.FAULT_SUBCODE_PROC_NOT_PRESENT);                throw new SAXException(fault);            } else {                throw new AxisFault(Constants.FAULT_CLIENT, Messages.getMessage("noSuchOperation", methodName),                        null, null);            }            } else {                 msgContext.setOperation(operation);            }        }        return operation;    }    protected RPCElement createResponseBody(RPCElement body, MessageContext msgContext, OperationDesc operation, ServiceDesc serviceDesc, Object objRes, SOAPEnvelope resEnv, ArrayList outs) throws Exception    {        String methodName = body.getMethodName();        /* Now put the result in the result SOAPEnvelope */        RPCElement resBody = new RPCElement(methodName + "Response");        resBody.setPrefix(body.getPrefix());        resBody.setNamespaceURI(body.getNamespaceURI());        resBody.setEncodingStyle(msgContext.getEncodingStyle());        try {            // Return first            if (operation.getMethod().getReturnType() != Void.TYPE) {                QName returnQName = operation.getReturnQName();                if (returnQName == null) {                    String nsp = body.getNamespaceURI();                    if(nsp == null || nsp.length()==0) {                        nsp = serviceDesc.getDefaultNamespace();                    }                    returnQName = new QName(msgContext.isEncoded() ? "" :                                                nsp,                                            methodName + "Return");                }                RPCParam param = new RPCParam(returnQName, objRes);                param.setParamDesc(operation.getReturnParamDesc());                if (!operation.isReturnHeader()) {                    // For SOAP 1.2 rpc style, add a result                    if (msgContext.getSOAPConstants() == SOAPConstants.SOAP12_CONSTANTS &&                            (serviceDesc.getStyle().equals(Style.RPC))) {                        RPCParam resultParam = new RPCParam(Constants.QNAME_RPC_RESULT, returnQName);                        resultParam.setXSITypeGeneration(Boolean.FALSE);                        resBody.addParam(resultParam);                    }                    resBody.addParam(param);                } else {                    resEnv.addHeader(new RPCHeaderParam(param));                }            }            // Then any other out params            if (!outs.isEmpty()) {                for (Iterator i = outs.iterator(); i.hasNext();) {                    // We know this has a holder, so just unwrap the value                    RPCParam param = (RPCParam) i.next();                    Holder holder = (Holder) param.getObjectValue();                    Object value = JavaUtils.getHolderValue(holder);                    ParameterDesc paramDesc = param.getParamDesc();                    param.setObjectValue(value);                    if (paramDesc != null && paramDesc.isOutHeader()) {                        resEnv.addHeader(new RPCHeaderParam(param));                    } else {                        resBody.addParam(param);                    }                }            }        } catch (Exception e) {            throw e;        }        return resBody;    }    /**     * This method encapsulates the method invocation.                  *     * @param msgContext MessageContext     * @param method the target method.     * @param obj the target object     * @param argValues the method arguments     */    protected Object invokeMethod(MessageContext msgContext,                                  Method method, Object obj,                                  Object[] argValues)            throws Exception {        return (method.invoke(obj, argValues));    }    /**     * Throw an AxisFault if the requested method is not allowed.     *     * @param msgContext MessageContext     * @param allowedMethods list of allowed methods     * @param methodName name of target method     */    protected void checkMethodName(MessageContext msgContext,                                   String allowedMethods,                                   String methodName)            throws Exception {        // Our version doesn't need to do anything, though inherited        // ones might.    }}

⌨️ 快捷键说明

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