private void addDocumentStyleOutputMessageToMethodInfo()

in src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/WSDLInfo.java [1366:1495]


    private void addDocumentStyleOutputMessageToMethodInfo(BindingEntry bindingEntry, Operation op, MethodInfo minfo) throws WrapperFault
    {
        if (op.getOutput() == null)
            return;

        Part part = null;

        // For now, skip over soap header parts
        Iterator returnlist = op.getOutput().getMessage().getParts().values().iterator();
        while (returnlist.hasNext())
        {
            part = (Part) returnlist.next();
            if (bindingEntry.isOutHeaderPart(op.getName(), part.getName()))
                part = null;
            else 
                break;
        }        
        
        // If no output parameter, simply return.
        if (part == null)
            return;

        
        QName qname;
        QName minfoqname;
        TypeEntry elementTypeEntry;
        
        Element element = c_symbolTable.getElement(part.getElementName());

        if (element == null)
        {
            elementTypeEntry = c_symbolTable.getType(part.getTypeName());
            qname            = elementTypeEntry.getQName();
            minfoqname       = elementTypeEntry.getQName();
        }
        else
        {
            elementTypeEntry = element.getRefType();
            qname            = elementTypeEntry.getQName();
            minfoqname       = element.getQName();
        }
        
        minfo.setOutputMessage(minfoqname);

        if (qname == null)
            return;
        
        Type type = c_typeMap.getType(qname);
        if (type == null)
            throw new WrapperFault("Unregistered type " + qname + " referenced!");

        // TODO - need to look into this more.
        // For wrapped style, inner attributes and elements are added as parameters.
        // For unwrapped style, objects are used for the parameters (i.e. classes or structures).
        
        Iterator elementNames = type.getElementnames();
        Iterator attributes   = type.getAttributes();
        if (!minfo.isUnwrapped())
        {
            if (!elementNames.hasNext())
            {
                // Type must be simple or primitive...we do a check just to make sure.
                if (type.isSimpleType() || type.isPrimitiveType())
                {
                    String elementName = (String) element.getQName().getLocalPart();
                    ParameterInfo pinfo = new ParameterInfo();
                    pinfo.setType(type);
                    pinfo.setParamName(elementName, c_typeMap);
                    pinfo.setElementName(element.getQName());
                    pinfo.setAnyElement(type.isAnyElement());
                    minfo.addOutputParameter(pinfo);                    
                    minfo.setConsumeBodyOnMessageValidation(false);
                }
            }
            else
            {
                while (elementNames.hasNext())
                {
                    String elementname  = (String) elementNames.next();
                    CElementDecl eleinfo = type.getElementForElementName(elementname);
                    Type innerType      = eleinfo.getType();
                    
                    ParameterInfo pinfo = new ParameterInfo();
                    pinfo.setType(innerType);
                    pinfo.setParamName(elementname, c_typeMap);
                    pinfo.setArray(eleinfo.getMaxOccurs() > 1);
                    pinfo.setNillable(eleinfo.isNillable());
                    pinfo.setOptional(eleinfo.getMinOccurs() == 0);
                    pinfo.setElementName(type.getElementForElementName(elementname).getName());
                    pinfo.setAnyElement(innerType.isAnyElement());
    
                    minfo.addOutputParameter(pinfo);
                }
            }
        }
        else
        { 
            // Ensure there is a response, if not, then operation is a one-way operation.
            if (type.isSimpleType() 
                    || type.isPrimitiveType()
                    || elementNames.hasNext() 
                    || (attributes != null && attributes.hasNext()))
            {
                String elementName = (String) element.getQName().getLocalPart();
                
                ParameterInfo pinfo = new ParameterInfo();
                pinfo.setType(type);
                type.setIsUnwrappedOutputType(true);
                pinfo.setParamName(elementName, c_typeMap);
                
                if (element != null)
                    pinfo.setElementName(element.getQName());
                else
                    pinfo.setElementName(type.getName());
                
                pinfo.setAnyElement(type.isAnyElement());
                
                // Let us be nice and uppercase the first character in type name, 
                // in addition to resolving method name/type conflicts.
                type.setLanguageSpecificName(generateNewTypeName(type, minfo));
                
                minfo.addOutputParameter(pinfo);
            }
            else if (!elementNames.hasNext())
            {
                // empty element....check message response but no deserialization necessary
                minfo.setConsumeBodyOnMessageValidation(true);
            }
        }
    }