public void setOperation()

in axis-rt-core/src/main/java/org/apache/axis/client/Call.java [1319:1575]


    public void setOperation(String opName) {
        if ( service == null ) {
            throw new JAXRPCException( Messages.getMessage("noService04") );
        }

        // remove all settings concerning an operation
        // leave portName and targetEndPoint as they are
        this.setOperationName( opName );
        this.setEncodingStyle( null );
        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;
        }

        Port port = wsdlService.getPort( portName.getLocalPart() );
        if ( port == null ) {
            throw new JAXRPCException( Messages.getMessage("noPort00", "" +
                                                           portName) );
        }

        Binding   binding  = port.getBinding();
        PortType  portType = binding.getPortType();
        if ( portType == null ) {
            throw new JAXRPCException( Messages.getMessage("noPortType00", "" +
                                                           portName) );
        }
        this.setPortTypeName(portType.getQName());
        
        List operations = portType.getOperations();
        if ( operations == null ) {
            throw new JAXRPCException( Messages.getMessage("noOperation01",
                                                           opName) );
        }

        Operation op = null ;
        for ( int i = 0 ; i < operations.size() ; i++, op=null ) {
            op = (Operation) operations.get( i );
            if ( opName.equals( op.getName() ) ) {
                break ;
            }
        }
        if ( op == null ) {
            throw new JAXRPCException( Messages.getMessage("noOperation01",
                                                           opName) );
        }

        // Get the SOAPAction
        ////////////////////////////////////////////////////////////////////
        List list = port.getExtensibilityElements();
        String opStyle = null;
        BindingOperation bop = binding.getBindingOperation(opName,
                                                           null, null);
        if ( bop == null ) {
            throw new JAXRPCException( Messages.getMessage("noOperation02",
                                                            opName ));
        }
        list = bop.getExtensibilityElements();
        for ( int i = 0 ; list != null && i < list.size() ; i++ ) {
            Object obj = list.get(i);
            if ( obj instanceof SOAPOperation ) {
                SOAPOperation sop    = (SOAPOperation) obj ;
                opStyle = ((SOAPOperation) obj).getStyle();
                String action = sop.getSoapActionURI();
                if ( action != null ) {
                    setUseSOAPAction(true);
                    setSOAPActionURI(action);
                }
                else {
                    setUseSOAPAction(false);
                    setSOAPActionURI(null);
                }
                break ;
            }
        }

        // Get the body's namespace URI and encoding style
        ////////////////////////////////////////////////////////////////////
        BindingInput bIn = bop.getBindingInput();
        if ( bIn != null ) {
            list = bIn.getExtensibilityElements();
            for ( int i = 0 ; list != null && i < list.size() ; i++ ) {
                Object obj = list.get(i);
                if( obj instanceof MIMEMultipartRelated){
                  MIMEMultipartRelated mpr=(MIMEMultipartRelated) obj;
                  Object part= null;
                  List l=  mpr.getMIMEParts();
                  for(int j=0; l!= null && j< l.size() && part== null; j++){
                     MIMEPart mp = (MIMEPart)l.get(j);
                     List ll= mp.getExtensibilityElements();
                     for(int k=0; ll != null && k < ll.size() && part == null;
                           k++){
                       part= ll.get(k);
                       if ( !(part instanceof SOAPBody)) {
                           part = null;
                       }
                     }
                  }
                  if(null != part) {
                      obj= part;
                  }
                }

                if ( obj instanceof SOAPBody ) {
                    SOAPBody sBody  = (SOAPBody) obj ;
                    list = sBody.getEncodingStyles();
                    if ( list != null && list.size() > 0 ) {
                        this.setEncodingStyle( (String) list.get(0) );
                    }
                    String ns = sBody.getNamespaceURI();
                    if (ns != null && !ns.equals("")) {
                      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;

    }