operationdescriptionimpl.java

来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 1,476 行 · 第 1/5 页

JAVA
1,476
字号
                        AxisOperationFactory.getOperationDescription(WSDL2Constants.MEP_URI_IN_OUT);
            }
            //TODO: There are several other MEP's, such as: OUT_ONLY, IN_OPTIONAL_OUT, OUT_IN, OUT_OPTIONAL_IN, ROBUST_OUT_ONLY,
            //                                              ROBUST_IN_ONLY
            //      Determine how these MEP's should be handled, if at all
        } catch (Exception e) {
            if (log.isDebugEnabled()) {
                log.debug(
                        "Unable to build AxisOperation for OperationDescrition; caught exception.",
                        e);
            }
            // TODO: NLS & RAS
            throw ExceptionFactory
                    .makeWebServiceException("Caught exception trying to create AxisOperation", e);
        }

        newAxisOperation.setName(determineOperationQName(this.methodComposite));
        newAxisOperation.setSoapAction(this.getAction());

        //*************************************************************************************
        //NOTE: assumption here is that all info. need to generate the actions will have to come
        //      from annotations (or default values)
        //*************************************************************************************
        
        String messageExchangePattern = newAxisOperation.getMessageExchangePattern();
        String targetNS = getEndpointInterfaceDescriptionImpl().getTargetNamespace();        
        String portTypeName = getEndpointInterfaceDescriptionImpl().getEndpointDescriptionImpl().getName();
        ArrayList inputActions = new ArrayList();
         
        //We don't have a name at this point, shouldn't matter if we have the MEP
        //String inputName = newAxisOperation.getName().getLocalPart();
        String inputName = null;
        String inputAction = 
                WSDL11ActionHelper.getInputActionFromStringInformation(messageExchangePattern, 
                                                                       targetNS, 
                                                                       portTypeName, 
                                                                       newAxisOperation.getName().getLocalPart(), 
                                                                       inputName);
                
        if (inputAction != null) {
            inputActions.add(inputAction);
            newAxisOperation.setWsamappingList(inputActions);
        }
        
        //Map the action to the operation on the actual axisService
        //TODO: Determine whether this should be done at a higher level in the 
        //      description hierarchy
        getEndpointInterfaceDescriptionImpl().getEndpointDescriptionImpl().
            getAxisService().mapActionToOperation(inputAction, newAxisOperation);
        
        //set the OUTPUT ACTION

        //We don't have a name at this point, shouldn't matter if we have the MEP
        //String outputName = newAxisOperation.getName().getLocalPart();  //REVIEW:
        String outputName = null;
        String outputAction = 
                WSDL11ActionHelper.getOutputActionFromStringInformation(messageExchangePattern,
                                                                        targetNS, 
                                                                        portTypeName, 
                                                                        newAxisOperation.getName().getLocalPart(), 
                                                                        outputName);
        
        if (outputAction != null) {
                newAxisOperation.setOutputAction(outputAction);
        }
        
        //Set the FAULT ACTION
        // Walk the fault information
        FaultDescription[] faultDescs = getFaultDescriptions();
        if (faultDescs != null) {
            for (int i=0; i <faultDescs.length; i++) {
        
                AxisMessage faultMessage = new AxisMessage();
                String faultName = faultDescs[i].getName();
                faultMessage.setName(faultName);
                
                String faultAction = 
                        WSDL11ActionHelper.getFaultActionFromStringInformation( messageExchangePattern, 
                                        portTypeName, 
                                        newAxisOperation.getName().getLocalPart(), 
                                        faultMessage.getName());
                
                if (faultAction != null) {
                        newAxisOperation.addFaultAction(faultMessage.getName(), faultAction);
                }
                newAxisOperation.setFaultMessages(faultMessage);
            }
        }

        //REVIEW: Determine if other axisOperation values may need to be set
        //      Currently, the following values are being set on AxisOperation in 
        //      ServiceBuilder.populateService which we are not setting:
        //          AxisOperation.setPolicyInclude()
        //          AxisOperation.setWsamappingList()
        //          AxisOperation.setOutputAction()
        //          AxisOperation.addFaultAction()
        //          AxisOperation.setFaultMessages()

        // If this is a DOC/LIT/BARE operation, then set the QName of the input AxisMessage to the 
        // part for the first IN or IN/OUT non-header parameter.  If there are no parameters, then don't set
        // anything.  The AxisMessage name is used to do SOAP-body based routing of DOC/LIT/BARE
        // incoming messages.
        if (getSoapBindingStyle() == javax.jws.soap.SOAPBinding.Style.DOCUMENT
                && getSoapBindingUse() == javax.jws.soap.SOAPBinding.Use.LITERAL
                && getSoapBindingParameterStyle() == javax.jws.soap.SOAPBinding.ParameterStyle.BARE)
        {
            ParameterDescription[] paramDescs = getParameterDescriptions();
            if (paramDescs != null && paramDescs.length > 0) {
                for (ParameterDescription paramDesc : paramDescs) {
                    WebParam.Mode paramMode = paramDesc.getMode();
                    if (!paramDesc.isHeader()
                            && (paramMode == WebParam.Mode.IN || paramMode == WebParam.Mode.INOUT))
                    {
                        // We've found the first IN or INOUT non-header parameter, so set the AxisMessage
                        // QName based on this parameter then break out of the loop.
                        AxisMessage axisMessage =
                                newAxisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
                        String elementName = paramDesc.getParameterName();
                        String partNamespace = paramDesc.getTargetNamespace();
                        if (log.isDebugEnabled()) {
                            log.debug("Setting up annotation based Doc/Lit/Bare operation: " +
                                    newAxisOperation.getName()
                                    + "; axisMessage: " + axisMessage + "; name: "
                                    + elementName + "; partTNS: " + partNamespace);
                        }
                        if (axisMessage == null) {
                            // TODO: RAS & NLS
                            throw ExceptionFactory.makeWebServiceException(
                                    "Could not setup Doc/Lit/Bare operation because input message is null");
                        } else if (DescriptionUtils.isEmpty(partNamespace)) {
                            // TODO: RAS & NLS
                            throw ExceptionFactory.makeWebServiceException(
                                    "Could not setup Doc/Lit/Bare operation because part namespace is empty");
                        } else if (DescriptionUtils.isEmpty(elementName)) {
                            // TODO: RAS & NLS
                            throw ExceptionFactory.makeWebServiceException(
                                    "Could not setup Doc/Lit/Bare operation because name is empty");
                        } else {
                            QName partQName = new QName(partNamespace, elementName);
                            if(log.isDebugEnabled()) {
                                log.debug("Setting AxisMessage element QName for bare mapping: " +
                                        partQName);
                            }
                            axisMessage.setElementQName(partQName);
                        }
                        break;
                    }
                }
            }
        }
        return newAxisOperation;
    }

    /**
     * Adds the AxisOperation corresponding to this OperationDescription to the AxisService if it
     * isn't already there. It also addes the AxisOperation to any other routing mechanisms for
     * that AxisService: - For Doc/Lit/Bare operations it is added to the
     * MessageElementQNameToOperationMapping
     *
     * @param axisService
     */
    void addToAxisService(AxisService axisService) {
        AxisOperation newAxisOperation = getAxisOperation();
        QName axisOpQName = newAxisOperation.getName();
        AxisOperation axisOperation = axisService.getOperation(axisOpQName);
        if (axisOperation == null) {
            axisService.addOperation(newAxisOperation);
            // For a Doc/Lit/Bare operation, we also need to add the element mapping
        }
        if (getSoapBindingStyle() == javax.jws.soap.SOAPBinding.Style.DOCUMENT
                && getSoapBindingUse() == javax.jws.soap.SOAPBinding.Use.LITERAL
                && getSoapBindingParameterStyle() == javax.jws.soap.SOAPBinding.ParameterStyle
                .BARE) {
            AxisMessage axisMessage =
                    null;
            if (axisOperation!=null) {
                axisMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
            } else {
                axisMessage = newAxisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
            }
            if (axisMessage != null) {
                QName elementQName = axisMessage.getElementQName();
                if (!DescriptionUtils.isEmpty(elementQName)) {
                    axisService.addMessageElementQNameToOperationMapping(elementQName,
                            newAxisOperation);
                }
            }
        }
    }

    void setSEIMethod(Method method) {
        if (seiMethod != null) {
            // TODO: This is probably an error, but error processing logic is incorrect
            throw new UnsupportedOperationException(
                    "Can not set an SEI method once it has been set.");
        } else {
            seiMethod = method;
            webMethodAnnotation = seiMethod.getAnnotation(WebMethod.class);
            parameterDescriptions = createParameterDescriptions();
            faultDescriptions = createFaultDescriptions();
        }
        // Register understood headers on axisOperation
        registerMustUnderstandHeaders();
    }

    public EndpointInterfaceDescription getEndpointInterfaceDescription() {
        return parentEndpointInterfaceDescription;
    }

    public EndpointInterfaceDescriptionImpl getEndpointInterfaceDescriptionImpl() {
        return (EndpointInterfaceDescriptionImpl)parentEndpointInterfaceDescription;
    }

    public AxisOperation getAxisOperation() {
        // Note that only the sync operations, and not the JAX-WS async client versions of an 
        // operation, will have an AxisOperation associated with it.  For those async operations, 
        // get the AxisOperation associated with the sync method and return that.
        if (axisOperation == null) {
            OperationDescription opDesc = getSyncOperation();
            if (opDesc != null && opDesc != this) {
                return getSyncOperation().getAxisOperation();
            }
        } 
        
        return axisOperation;
    }

    public QName getName() {
        return operationQName;
    }

    // Java-related getters
    public String getJavaMethodName() {
        String returnString = null;

        if (!isDBC()) {
            if (seiMethod != null) {
                returnString = seiMethod.getName();
            }
        } else {
            if (methodComposite != null) {
                returnString = methodComposite.getMethodName();
            }
        }

        return returnString;
    }

    public String getJavaDeclaringClassName() {
        if (!isDBC() && seiMethod != null) {
            Class clazz = seiMethod.getDeclaringClass();
            return clazz.getCanonicalName();
        } else if (methodComposite != null) {
            return methodComposite.getDeclaringClass();
        }
        return null;
    }

    public String[] getJavaParameters() {

        ArrayList<String> returnParameters = new ArrayList<String>();

        if (!isDBC()) {
            if (seiMethod != null) {
                Class[] paramaters = seiMethod.getParameterTypes();
                for (Class param : paramaters) {
                    returnParameters.add(param.getName());
                }
            }

        } else {
            if (methodComposite != null) {

                Iterator<ParameterDescriptionComposite> iter =
                        methodComposite.getParameterDescriptionCompositeList().iterator();
                while (iter.hasNext()) {
                    returnParameters.add(iter.next().getParameterType());
                }
            }
        }

        // TODO: This is different than the rest, which return null instead of an empty array
        return returnParameters.toArray(new String[0]);
    }

    /**
     * Note this will return NULL unless the operation was built via introspection on the SEI. In
     * other words, it will return null if the operation was built with WSDL.
     *
     * @return
     */
    public Method getSEIMethod() {
        return seiMethod;
    }

    MethodDescriptionComposite getMethodDescriptionComposite() {

⌨️ 快捷键说明

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