geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r155737 - in geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder: AxisBuilder.java HeavyweightOperationDescBuilder.java LightweightOperationDescBuilder.java OperationDescBuilder.java TypeDescBuilder.java
Date Tue, 01 Mar 2005 02:36:45 GMT
Author: dblevins
Date: Mon Feb 28 18:36:44 2005
New Revision: 155737

URL: http://svn.apache.org/viewcvs?view=rev&rev=155737
Log:
Split the AxisBuilder apart so it can be more easily reused for building the server-side web services.

Added:
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/LightweightOperationDescBuilder.java
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/OperationDescBuilder.java
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/TypeDescBuilder.java
Modified:
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java

Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java?view=diff&r1=155736&r2=155737
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java (original)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java Mon Feb 28 18:36:44 2005
@@ -25,32 +25,11 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Collections;
+import java.util.*;
 import java.util.jar.JarFile;
-import java.beans.PropertyDescriptor;
-import java.beans.Introspector;
-import java.beans.IntrospectionException;
-import javax.wsdl.Binding;
-import javax.wsdl.BindingInput;
-import javax.wsdl.BindingOperation;
-import javax.wsdl.Definition;
-import javax.wsdl.Fault;
-import javax.wsdl.Message;
-import javax.wsdl.Operation;
-import javax.wsdl.Part;
-import javax.wsdl.Port;
-import javax.wsdl.PortType;
+import javax.wsdl.*;
 import javax.wsdl.extensions.soap.SOAPAddress;
 import javax.wsdl.extensions.soap.SOAPBinding;
-import javax.wsdl.extensions.soap.SOAPBody;
-import javax.wsdl.extensions.soap.SOAPOperation;
 import javax.xml.namespace.QName;
 import javax.xml.rpc.handler.HandlerInfo;
 
@@ -63,28 +42,13 @@
 import net.sf.cglib.reflect.FastConstructor;
 import org.apache.axis.client.Service;
 import org.apache.axis.constants.Style;
-import org.apache.axis.constants.Use;
-import org.apache.axis.description.FaultDesc;
-import org.apache.axis.description.OperationDesc;
-import org.apache.axis.description.ParameterDesc;
 import org.apache.axis.description.TypeDesc;
-import org.apache.axis.description.FieldDesc;
-import org.apache.axis.description.AttributeDesc;
-import org.apache.axis.description.ElementDesc;
 import org.apache.axis.encoding.ser.ArrayDeserializerFactory;
 import org.apache.axis.encoding.ser.ArraySerializerFactory;
 import org.apache.axis.encoding.ser.BeanDeserializerFactory;
 import org.apache.axis.encoding.ser.BeanSerializerFactory;
 import org.apache.axis.soap.SOAPConstants;
-import org.apache.geronimo.axis.client.GenericServiceEndpointWrapper;
-import org.apache.geronimo.axis.client.NoOverrideCallbackFilter;
-import org.apache.geronimo.axis.client.OperationInfo;
-import org.apache.geronimo.axis.client.SEIFactory;
-import org.apache.geronimo.axis.client.SEIFactoryImpl;
-import org.apache.geronimo.axis.client.SerializableNoOp;
-import org.apache.geronimo.axis.client.ServiceImpl;
-import org.apache.geronimo.axis.client.ServiceMethodInterceptor;
-import org.apache.geronimo.axis.client.TypeMappingInfo;
+import org.apache.geronimo.axis.client.*;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.gbean.GBeanData;
@@ -96,22 +60,11 @@
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.ClassLoading;
 import org.apache.geronimo.naming.reference.DeserializingReference;
-import org.apache.geronimo.xbeans.j2ee.ConstructorParameterOrderType;
-import org.apache.geronimo.xbeans.j2ee.ExceptionMappingType;
 import org.apache.geronimo.xbeans.j2ee.JavaWsdlMappingType;
 import org.apache.geronimo.xbeans.j2ee.JavaXmlTypeMappingType;
-import org.apache.geronimo.xbeans.j2ee.MethodParamPartsMappingType;
 import org.apache.geronimo.xbeans.j2ee.ServiceEndpointInterfaceMappingType;
 import org.apache.geronimo.xbeans.j2ee.ServiceEndpointMethodMappingType;
-import org.apache.geronimo.xbeans.j2ee.WsdlMessageMappingType;
-import org.apache.geronimo.xbeans.j2ee.WsdlReturnValueMappingType;
-import org.apache.geronimo.xbeans.j2ee.VariableMappingType;
 import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.SchemaProperty;
-import org.objectweb.asm.Type;
-import org.w3.x2001.xmlSchema.ComplexType;
-import org.w3.x2001.xmlSchema.ExplicitGroup;
-import org.w3.x2001.xmlSchema.LocalElement;
 
 /**
  * @version $Rev:  $ $Date:  $
@@ -397,69 +350,7 @@
     }
 
     private TypeDesc getTypeDescriptor(Class javaClass, QName typeQName, JavaXmlTypeMappingType javaXmlTypeMapping, SchemaType schemaType) throws DeploymentException {
-        boolean isRestriction = schemaType.getDerivationType() == SchemaType.DT_RESTRICTION;
-        TypeDesc typeDesc = new TypeDesc(javaClass, !isRestriction);
-        //TODO typeQName may be a 'anonymous" QName like construct.  Is this what axis expects?
-        typeDesc.setXmlType(typeQName);
-        VariableMappingType[] variableMappings = javaXmlTypeMapping.getVariableMappingArray();
-        FieldDesc[] fields = new FieldDesc[variableMappings.length];
-
-        PropertyDescriptor[] propertyDescriptors = new java.beans.PropertyDescriptor[0];
-        try {
-            propertyDescriptors = Introspector.getBeanInfo(javaClass).getPropertyDescriptors();
-        } catch (IntrospectionException e) {
-            throw new DeploymentException("Class " + javaClass + " is not a valid javabean", e);
-        }
-        Map properties = new HashMap();
-        for (int i = 0; i < propertyDescriptors.length; i++) {
-            PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
-            properties.put(propertyDescriptor.getName(), propertyDescriptor.getPropertyType());
-        }
-        for (int i = 0; i < variableMappings.length; i++) {
-            VariableMappingType variableMapping = variableMappings[i];
-            String fieldName = variableMapping.getJavaVariableName().getStringValue().trim();
-
-            if (variableMapping.isSetXmlAttributeName()) {
-                AttributeDesc attributeDesc = new AttributeDesc();
-                //setting attribute name sets the xmlName with "" namespace, so don't do it
-//                attributeDesc.setAttributeName(fieldName);
-                attributeDesc.setFieldName(fieldName);
-                Class javaType = (Class) properties.get(fieldName);
-                if (javaType == null) {
-                    throw new DeploymentException("field name " + fieldName + " not found in " + properties);
-                }
-                attributeDesc.setJavaType(javaType);
-                //TODO correct namespace???
-                String namespace = "";
-                QName xmlName = new QName(namespace, variableMapping.getXmlAttributeName().getStringValue().trim());
-                attributeDesc.setXmlName(xmlName);
-                QName xmlType = schemaType.getName();
-                attributeDesc.setXmlType(xmlType);
-                fields[i] = attributeDesc;
-            } else {
-                ElementDesc elementDesc = new ElementDesc();
-                elementDesc.setFieldName(fieldName);
-                Class javaType = (Class) properties.get(fieldName);
-                if (javaType == null) {
-                    throw new DeploymentException("field name " + fieldName + " not found in " + properties);
-                }
-                elementDesc.setJavaType(javaType);
-                //TODO correct namespace???
-                String namespace = "";
-                QName xmlName = new QName(namespace, variableMapping.getXmlElementName().getStringValue().trim());
-                elementDesc.setXmlName(xmlName);
-                QName xmlType = schemaType.getName();
-                elementDesc.setXmlType(xmlType);
-                //TODO figure out how to find these:
-//                elementDesc.setArrayType(null);
-//                elementDesc.setMinOccurs(0);
-//                elementDesc.setMaxOccurs(0);
-//                elementDesc.setNillable(false);
-                fields[i] = elementDesc;
-            }
-        }
-        typeDesc.setFields(fields);
-        return typeDesc;
+        return TypeDescBuilder.getTypeDescriptor(javaClass, typeQName, javaXmlTypeMapping, schemaType);
     }
 
     private Method getMethodForOperation(Class enhancedServiceEndpointClass, Operation operation) throws DeploymentException {
@@ -546,343 +437,13 @@
     }
 
     public OperationInfo buildOperationInfoLightweight(Method method, BindingOperation bindingOperation, Style defaultStyle, SOAPConstants soapVersion) throws DeploymentException {
-
-        if (bindingOperation == null) {
-            throw new DeploymentException("No BindingOperation supplied for method " + method.getName());
-        }
-        Operation operation = bindingOperation.getOperation();
-        String operationName = operation.getName();
-        //section 7.3.2, we don't have to look at parameter ordering.
-        //unless it turns out we have to validate it.
-//        List order = operation.getParameterOrdering();
-        List parameterList = new ArrayList();
-
-        QName returnType = null;
-        QName returnQName = null;
-
-        Message inputMessage = operation.getInput().getMessage();
-        Message outputMessage = operation.getOutput() == null ? null : operation.getOutput().getMessage();
-
-        if (outputMessage != null && outputMessage.getParts().size() > 1) {
-            throw new DeploymentException("Lightweight mapping has at most one part in the (optional) output message, not: " + outputMessage.getParts().size());
-        }
-        Class[] methodParamTypes = method.getParameterTypes();
-        List inputParts = inputMessage.getOrderedParts(null);
-        if (methodParamTypes.length != inputParts.size()) {
-            throw new DeploymentException("mismatch in parameter counts: method has " + methodParamTypes.length + " whereas the input message has " + inputParts.size());
-        }
-        int i = 0;
-        for (Iterator parts = inputParts.iterator(); parts.hasNext();) {
-            Part part = (Part) parts.next();
-            String partName = part.getName();
-            QName name = new QName("", partName);
-            byte mode = ParameterDesc.IN;
-            QName typeQName = part.getTypeName() == null ? part.getElementName() : part.getTypeName();
-            Class javaClass = methodParamTypes[i++];
-            //lightweight mapping has no parts in headers, so inHeader and outHeader are false
-            ParameterDesc parameter = new ParameterDesc(name, mode, typeQName, javaClass, false, false);
-            parameterList.add(parameter);
-        }
-        if (outputMessage != null && outputMessage.getParts().size() == 1) {
-            returnQName = outputMessage.getQName();
-            Part part = (Part) outputMessage.getParts().values().iterator().next();
-            returnType = part.getTypeName() == null ? part.getElementName() : part.getTypeName();
-        }
-        ParameterDesc[] parameterDescs = (ParameterDesc[]) parameterList.toArray(new ParameterDesc[parameterList.size()]);
-        OperationDesc operationDesc = new OperationDesc(operationName, parameterDescs, returnQName);
-        operationDesc.setReturnType(returnType);
-        Class returnClass = method.getReturnType();
-        operationDesc.setReturnClass(returnClass);
-
-        SOAPOperation soapOperation = (SOAPOperation) WSDescriptorParser.getExtensibilityElement(SOAPOperation.class, bindingOperation.getExtensibilityElements());
-        String soapActionURI = soapOperation.getSoapActionURI();
-        String styleString = soapOperation.getStyle();
-        Style style = Style.getStyle(styleString, defaultStyle);
-        BindingInput bindingInput = bindingOperation.getBindingInput();
-        SOAPBody soapBody = (SOAPBody) WSDescriptorParser.getExtensibilityElement(SOAPBody.class, bindingInput.getExtensibilityElements());
-        String useString = soapBody.getUse();
-        Use use = Use.getUse(useString);
-        operationDesc.setStyle(style);
-        operationDesc.setUse(use);
-        //TODO add faults
-//        TFault[] faults = tOperation.getFaultArray();
-//        for (int i = 0; i < faults.length; i++) {
-//            TFault fault = faults[i];
-//            QName faultQName = new QName("", fault.getName());
-//            String className = ;
-//            QName faultTypeQName = ;
-//            boolean isComplex = ;
-//            FaultDesc faultDesc = new FaultDesc(faultQName, className, faultTypeQName, isComplex)
-//        }
-        boolean usesSOAPAction = (soapActionURI != null);
-        QName operationQName = new QName("", operation.getName());
-
-        String methodName = method.getName();
-        String methodDesc = Type.getMethodDescriptor(method);
-        OperationInfo operationInfo = new OperationInfo(operationDesc, usesSOAPAction, soapActionURI, soapVersion, operationQName, methodName, methodDesc);
-        return operationInfo;
+        LightweightOperationDescBuilder operationDescBuilder = new LightweightOperationDescBuilder(bindingOperation, method);
+        return operationDescBuilder.buildOperationInfo(soapVersion);
     }
 
     public OperationInfo buildOperationInfoHeavyweight(ServiceEndpointMethodMappingType methodMapping, BindingOperation bindingOperation, Style defaultStyle, SOAPConstants soapVersion, Map exceptionMap, Map complexTypeMap, JavaWsdlMappingType mapping, ClassLoader classLoader) throws DeploymentException {
-
-        //TODO how can bindingOperation be null?
-        Operation operation = bindingOperation.getOperation();
-        String operationName = operation.getName();
-
-
-        Message inputMessage = operation.getInput().getMessage();
-        Message outputMessage = operation.getOutput() == null ? null : operation.getOutput().getMessage();
-
-        boolean isWrappedElement = methodMapping.isSetWrappedElement();
-
-        MethodParamPartsMappingType[] paramMappings = methodMapping.getMethodParamPartsMappingArray();
-        Type[] parameterASMTypes = new Type[paramMappings.length];
-        ParameterDesc[] parameterDescriptions = new ParameterDesc[paramMappings.length];
-
-        Set inParamNames = new HashSet();
-        Set outParamNames = new HashSet();
-        for (int i = 0; i < paramMappings.length; i++) {
-            MethodParamPartsMappingType paramMapping = paramMappings[i];
-            int position = paramMapping.getParamPosition().getBigIntegerValue().intValue();
-
-            WsdlMessageMappingType wsdlMessageMappingType = paramMapping.getWsdlMessageMapping();
-            QName wsdlMessageQName = wsdlMessageMappingType.getWsdlMessage().getQNameValue();
-            String wsdlMessagePartName = wsdlMessageMappingType.getWsdlMessagePartName().getStringValue().trim();
-
-            String parameterMode = wsdlMessageMappingType.getParameterMode().getStringValue().trim();
-            byte mode = ParameterDesc.modeFromString(parameterMode);
-            boolean isInParam = mode == ParameterDesc.IN || mode == ParameterDesc.INOUT;
-            boolean isOutParam = mode == ParameterDesc.OUT || mode == ParameterDesc.INOUT;
-
-            if (isOutParam && outputMessage == null) {
-                throw new DeploymentException("Mapping for output parameter " + wsdlMessagePartName + " found, but no output message for operation " + operationName);
-            }
-            boolean isSoapHeader = wsdlMessageMappingType.isSetSoapHeader();
-            boolean inHeader = isSoapHeader && isInParam;
-            boolean outHeader = isSoapHeader && isOutParam;
-
-            Part part;
-            if (isInParam) {
-                if (!wsdlMessageQName.equals(inputMessage.getQName())) {
-                    throw new DeploymentException("QName of input message: " + inputMessage.getQName() +
-                            " does not match mapping message QName: " + wsdlMessageQName + " for operation " + operationName);
-                }
-                part = inputMessage.getPart(wsdlMessagePartName);
-                if (part == null) {
-                    throw new DeploymentException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in input message for operation " + operationName);
-                }
-                inParamNames.add(wsdlMessagePartName);
-                if (isOutParam) {
-                    //inout, check that part of same name and type is in output message
-                    Part outPart = outputMessage.getPart(wsdlMessagePartName);
-                    if (outPart == null) {
-                        throw new DeploymentException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in output message for INOUT parameter of operation " + operationName);
-                    }
-                    if (!part.getName().equals(outPart.getName())) {
-                        throw new DeploymentException("Mismatched input part name: " + part.getName() + " and output part name: " + outPart.getName() + " for INOUT parameter for wsdlMessagePartName " + wsdlMessagePartName + " for operation " + operationName);
-                    }
-                    if (!(part.getElementName() == null ? outPart.getElementName() == null : part.getElementName().equals(outPart.getElementName()))) {
-                        throw new DeploymentException("Mismatched input part element name: " + part.getElementName() + " and output part element name: " + outPart.getElementName() + " for INOUT parameter for wsdlMessagePartName " + wsdlMessagePartName + " for operation " + operationName);
-                    }
-                    if (!(part.getTypeName() == null ? outPart.getTypeName() == null : part.getTypeName().equals(outPart.getTypeName()))) {
-                        throw new DeploymentException("Mismatched input part type name: " + part.getTypeName() + " and output part type name: " + outPart.getTypeName() + " for INOUT parameter for wsdlMessagePartName " + wsdlMessagePartName + " for operation " + operationName);
-                    }
-                    outParamNames.add(wsdlMessagePartName);
-                }
-            } else if (isOutParam) {
-                if (!wsdlMessageQName.equals(outputMessage.getQName())) {
-                    throw new DeploymentException("QName of output message: " + outputMessage.getQName() +
-                            " does not match mapping message QName: " + wsdlMessageQName + " for operation " + operationName);
-                }
-                part = outputMessage.getPart(wsdlMessagePartName);
-                if (part == null) {
-                    throw new DeploymentException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in output message for operation " + operationName);
-                }
-                outParamNames.add(wsdlMessagePartName);
-            } else {
-                throw new AssertionError("a param mapping has to be IN or OUT or INOUT");
-            }
-
-            //TODO this makes little sense but may be correct, see comments in axis Parameter class
-            //the part name qname is really odd.
-            QName partQName = isWrappedElement ? part.getElementName() : new QName("", part.getName());
-            QName partTypeQName = part.getTypeName();
-
-            //use complexTypeMap
-            boolean isComplexType = complexTypeMap.containsKey(partTypeQName);
-            String paramJavaTypeName = paramMapping.getParamType().getStringValue().trim();
-            boolean isInOnly = mode == ParameterDesc.IN;
-            Class actualParamJavaType = WSDescriptorParser.getHolderType(paramJavaTypeName, isInOnly, partTypeQName, isComplexType, mapping, classLoader);
-
-            ParameterDesc parameterDesc = new ParameterDesc(partQName, mode, partTypeQName, actualParamJavaType, inHeader, outHeader);
-            parameterDescriptions[position] = parameterDesc;
-            parameterASMTypes[position] = Type.getType(actualParamJavaType);
-        }
-
-        //check that all the parameters are there
-        for (int i = 0; i < parameterDescriptions.length; i++) {
-            ParameterDesc parameterDescription = parameterDescriptions[i];
-            if (parameterDescription == null) {
-                throw new DeploymentException("There is no mapping for parameter number " + i + " for operation " + operationName);
-            }
-        }
-
-        //check that all input message parts are mapped
-        if (!inParamNames.equals(inputMessage.getParts().keySet())) {
-            throw new DeploymentException("Not all input message parts were mapped for operation name" + operationName);
-        }
-
-
-        QName returnType = null;
-        QName returnQName = null;
-        Class returnClass = null;
-        Type returnASMType = Type.VOID_TYPE;
-
-        if (methodMapping.isSetWsdlReturnValueMapping()) {
-            if (outputMessage == null) {
-                throw new DeploymentException("No output message, but a mapping for it for operation " + operationName);
-            }
-            WsdlReturnValueMappingType wsdlReturnValueMapping = methodMapping.getWsdlReturnValueMapping();
-            String returnClassName = wsdlReturnValueMapping.getMethodReturnValue().getStringValue().trim();
-            try {
-                returnClass = ClassLoading.loadClass(returnClassName, classLoader);
-            } catch (ClassNotFoundException e) {
-                throw new DeploymentException("Could not load return type for operation " + operationName, e);
-            }
-
-            QName wsdlMessageQName = wsdlReturnValueMapping.getWsdlMessage().getQNameValue();
-
-            if (!wsdlMessageQName.equals(outputMessage.getQName())) {
-                throw new DeploymentException("OutputMessage has QName: " + outputMessage.getQName() + " but mapping specifies: " + wsdlMessageQName + " for operation " + operationName);
-            }
-
-            if (wsdlReturnValueMapping.isSetWsdlMessagePartName()) {
-                String wsdlMessagePartName = wsdlReturnValueMapping.getWsdlMessagePartName().getStringValue().trim();
-                if (outParamNames.contains(wsdlMessagePartName)) {
-                    throw new DeploymentException("output message part " + wsdlMessagePartName + " has both an INOUT or OUT mapping and a return value mapping for operation " + operationName);
-                }
-                Part part = outputMessage.getPart(wsdlMessagePartName);
-                returnQName = part.getElementName();
-                returnType = part.getTypeName();
-
-                outParamNames.add(wsdlMessagePartName);
-
-            } else {
-                //what does this mean????
-            }
-
-            returnASMType = Type.getType(returnClass);
-
-        }
-
-        if (outputMessage != null && !outParamNames.equals(outputMessage.getParts().keySet())) {
-            throw new DeploymentException("Not all output message parts were mapped to parameters or a return value for operation " + operationName);
-        }
-
-        OperationDesc operationDesc = new OperationDesc(operationName, parameterDescriptions, returnQName);
-        operationDesc.setReturnType(returnType);
-        operationDesc.setReturnClass(returnClass);
-
-        SOAPOperation soapOperation = (SOAPOperation) WSDescriptorParser.getExtensibilityElement(SOAPOperation.class, bindingOperation.getExtensibilityElements());
-        String soapActionURI = soapOperation.getSoapActionURI();
-        String styleString = soapOperation.getStyle();
-        Style style = Style.getStyle(styleString, defaultStyle);
-        BindingInput bindingInput = bindingOperation.getBindingInput();
-        SOAPBody soapBody = (SOAPBody) WSDescriptorParser.getExtensibilityElement(SOAPBody.class, bindingInput.getExtensibilityElements());
-        String useString = soapBody.getUse();
-        Use use = Use.getUse(useString);
-        operationDesc.setStyle(style);
-        operationDesc.setUse(use);
-        //TODO add faults
-
-        Map faultMap = operation.getFaults();
-        for (Iterator iterator = faultMap.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String faultName = (String) entry.getKey();
-            Fault fault = (Fault) entry.getValue();
-            Message message = fault.getMessage();
-            QName messageQName = message.getQName();
-            ExceptionMappingType exceptionMapping = (ExceptionMappingType) exceptionMap.get(messageQName);
-            if (exceptionMapping == null) {
-                throw new DeploymentException("No exception mapping for fault " + faultName + " and fault message " + messageQName + " for operation " + operationName);
-            }
-            String className = exceptionMapping.getExceptionType().getStringValue().trim();
-            //this is weird, but I can't figure out what it should be.
-            QName faultQName = new QName("", faultName);
-            Part part;
-            if (exceptionMapping.isSetWsdlMessagePartName()) {
-                //According to schema documentation, this will only be set when several headerfaults use the same message.
-                String headerFaultMessagePartName = exceptionMapping.getWsdlMessagePartName().getStringValue();
-                part = message.getPart(headerFaultMessagePartName);
-            } else {
-                part = (Part) message.getOrderedParts(null).iterator().next();
-            }
-            QName faultTypeQName = part.getElementName() == null ? part.getTypeName() : part.getElementName();
-            boolean isComplex = faultTypeQName != null && complexTypeMap.containsKey(faultTypeQName);
-            FaultDesc faultDesc = new FaultDesc(faultQName, className, faultTypeQName, isComplex);
-
-            //constructor parameters
-            if (exceptionMapping.isSetConstructorParameterOrder()) {
-                if (!isComplex) {
-                    throw new DeploymentException("ConstructorParameterOrder can only be set for complex types, not " + faultTypeQName);
-                }
-                SchemaType complexType = (SchemaType) complexTypeMap.get(faultTypeQName);
-                Map elementMap = new HashMap();
-                SchemaProperty[] properties = complexType.getProperties();
-                for (int i = 0; i < properties.length; i++) {
-                    SchemaProperty property = properties[i];
-                    QName elementName = property.getName();
-                    SchemaType elementType = property.getType();
-                    QName elementTypeQName = elementType.getName();
-                    elementMap.put(elementName.getLocalPart(), elementTypeQName);
-                }
-//                LocalElement[] elements = explicitGroup.getElementArray();
-//                for (int i = 0; i < elements.length; i++) {
-//                    LocalElement element = elements[i];
-//                    String elementName = element.getName();
-//                    QName elementType = element.getType();
-//                    elementMap.put(elementName, elementType);
-//                }
-                ArrayList parameterTypes = new ArrayList();
-                ConstructorParameterOrderType constructorParameterOrder = exceptionMapping.getConstructorParameterOrder();
-                for (int i = 0; i < constructorParameterOrder.getElementNameArray().length; i++) {
-                    String elementName = constructorParameterOrder.getElementNameArray(i).getStringValue().trim();
-                    QName elementType = (QName) elementMap.get(elementName);
-                    String javaElementTypeName;
-                    if (complexTypeMap.containsKey(elementType)) {
-                        String packageName = WSDescriptorParser.getPackageFromNamespace(elementType.getNamespaceURI(), mapping);
-                        javaElementTypeName = packageName + "." + elementType.getLocalPart();
-                    } else {
-                        //TODO finish this
-                        if (elementType.getLocalPart().equals("String")) {
-                            javaElementTypeName = String.class.getName();
-                        } else {
-                            throw new DeploymentException("most simple exception constructor types not yet implemented");
-                        }
-                    }
-                    Class javaElementType;
-                    try {
-                        javaElementType = ClassLoading.loadClass(javaElementTypeName, classLoader);
-                    } catch (ClassNotFoundException e) {
-                        throw new DeploymentException("Could not load exception constructor parameter", e);
-                    }
-                    //todo faultTypeQName is speculative
-                    //todo outheader might be true!
-                    ParameterDesc parameterDesc = new ParameterDesc(faultTypeQName, ParameterDesc.OUT, elementType, javaElementType, false, false);
-                    parameterTypes.add(parameterDesc);
-                }
-                faultDesc.setParameters(parameterTypes);
-            }
-            operationDesc.addFault(faultDesc);
-        }
-
-        boolean usesSOAPAction = (soapActionURI != null);
-        QName operationQName = new QName("", operation.getName());
-
-        String methodName = methodMapping.getJavaMethodName().getStringValue().trim();
-        String methodDesc = Type.getMethodDescriptor(returnASMType, parameterASMTypes);
-        OperationInfo operationInfo = new OperationInfo(operationDesc, usesSOAPAction, soapActionURI, soapVersion, operationQName, methodName, methodDesc);
-        return operationInfo;
+        HeavyweightOperationDescBuilder operationDescBuilder = new HeavyweightOperationDescBuilder(bindingOperation, mapping, methodMapping, defaultStyle, exceptionMap, complexTypeMap, classLoader);
+        return operationDescBuilder.buildOperationInfo(soapVersion);
     }
 
     private static class ByteArrayRetrievingGeneratorStrategy extends DefaultGeneratorStrategy {

Added: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java?view=auto&rev=155737
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java (added)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java Mon Feb 28 18:36:44 2005
@@ -0,0 +1,357 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.axis.builder;
+
+import java.lang.String;
+import java.util.*;
+import javax.wsdl.*;
+import javax.wsdl.extensions.soap.SOAPBody;
+import javax.xml.namespace.QName;
+
+import org.apache.axis.constants.Style;
+import org.apache.axis.constants.Use;
+import org.apache.axis.description.FaultDesc;
+import org.apache.axis.description.OperationDesc;
+import org.apache.axis.description.ParameterDesc;
+import org.apache.axis.soap.SOAPConstants;
+import org.apache.geronimo.axis.client.OperationInfo;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.kernel.ClassLoading;
+import org.apache.geronimo.xbeans.j2ee.*;
+import org.apache.xmlbeans.SchemaProperty;
+import org.apache.xmlbeans.SchemaType;
+import org.objectweb.asm.Type;
+
+public class HeavyweightOperationDescBuilder extends OperationDescBuilder {
+
+    private final JavaWsdlMappingType mapping;
+    private final ServiceEndpointMethodMappingType methodMapping;
+    private final SOAPBody soapBody;
+
+
+    private final Style defaultStyle;
+    private final Map exceptionMap;
+    private final Map complexTypeMap;
+    private final ClassLoader classLoader;
+
+    /* Keep track of in and out parameter names so we can verify that
+     * everything has been mapped and mapped correctly
+     */
+    private final Set inParamNames = new HashSet();
+    private final Set outParamNames = new HashSet();
+
+    public HeavyweightOperationDescBuilder(BindingOperation bindingOperation, JavaWsdlMappingType mapping, ServiceEndpointMethodMappingType methodMapping, Style defaultStyle, Map exceptionMap, Map complexTypeMap, ClassLoader classLoader) throws DeploymentException {
+        super(bindingOperation);
+        this.mapping = mapping;
+        this.methodMapping = methodMapping;
+        this.defaultStyle = defaultStyle;
+        this.exceptionMap = exceptionMap;
+        this.complexTypeMap = complexTypeMap;
+        this.classLoader = classLoader;
+
+        BindingInput bindingInput = bindingOperation.getBindingInput();
+        this.soapBody = (SOAPBody) WSDescriptorParser.getExtensibilityElement(SOAPBody.class, bindingInput.getExtensibilityElements());
+    }
+
+
+    public OperationInfo buildOperationInfo(SOAPConstants soapVersion) throws DeploymentException {
+        buildOperationDesc();
+
+        String soapActionURI = soapOperation.getSoapActionURI();
+        boolean usesSOAPAction = (soapActionURI != null);
+        QName operationQName = new QName("", operation.getName());
+
+        String methodName = methodMapping.getJavaMethodName().getStringValue().trim();
+
+        ArrayList parameters = operationDesc.getParameters();
+        Type[] parameterASMTypes = new Type[parameters.size()];
+        for (int i = 0; i < parameters.size(); i++) {
+            ParameterDesc parameterDesc = (ParameterDesc) parameters.get(i);
+            parameterASMTypes[i] = Type.getType(parameterDesc.getJavaType());
+        }
+
+        Type returnASMType = (operationDesc.getReturnClass() != null) ? Type.getType(operationDesc.getReturnClass()) : Type.VOID_TYPE;
+
+        String methodDesc = Type.getMethodDescriptor(returnASMType, parameterASMTypes);
+        OperationInfo operationInfo = new OperationInfo(operationDesc, usesSOAPAction, soapActionURI, soapVersion, operationQName, methodName, methodDesc);
+        return operationInfo;
+    }
+
+    public OperationDesc buildOperationDesc() throws DeploymentException {
+        if (built) {
+            return operationDesc;
+        }
+        built = true;
+
+        // Set to 'document' or 'rpc'
+        Style style = Style.getStyle(soapOperation.getStyle(), defaultStyle);
+        operationDesc.setStyle(style);
+
+        // Set to 'encoded' or 'literal'
+        Use use = Use.getUse(soapBody.getUse());
+        operationDesc.setUse(use);
+
+
+        boolean isWrappedElement = methodMapping.isSetWrappedElement();
+
+        MethodParamPartsMappingType[] paramMappings = methodMapping.getMethodParamPartsMappingArray();
+
+        /* Put the ParameterDesc instance in an array so they can be ordered properly
+         * before they are added to the the OperationDesc.
+         */
+        ParameterDesc[] parameterDescriptions = new ParameterDesc[paramMappings.length];
+
+
+        // MAP PARAMETERS
+        for (int i = 0; i < paramMappings.length; i++) {
+            MethodParamPartsMappingType paramMapping = paramMappings[i];
+            int position = paramMapping.getParamPosition().getBigIntegerValue().intValue();
+
+            ParameterDesc parameterDesc = mapParameter(paramMapping, isWrappedElement);
+
+            parameterDescriptions[position] = parameterDesc;
+        }
+
+        //check that all input message parts are mapped
+        if (!inParamNames.equals(input.getParts().keySet())) {
+            throw new DeploymentException("Not all input message parts were mapped for operation name" + operationName);
+        }
+
+        //check that all the parameters are there
+        for (int i = 0; i < parameterDescriptions.length; i++) {
+            ParameterDesc parameterDescription = parameterDescriptions[i];
+            if (parameterDescription == null) {
+                throw new DeploymentException("There is no mapping for parameter number " + i + " for operation " + operationName);
+            }
+            operationDesc.addParameter(parameterDescription);
+        }
+
+        // MAP RETURN TYPE
+        if (methodMapping.isSetWsdlReturnValueMapping()) {
+            mapReturnType();
+
+        }
+
+        if (output != null && !outParamNames.equals(output.getParts().keySet())) {
+            throw new DeploymentException("Not all output message parts were mapped to parameters or a return value for operation " + operationName);
+        }
+
+        Map faultMap = operation.getFaults();
+        for (Iterator iterator = faultMap.entrySet().iterator(); iterator.hasNext();) {
+            Map.Entry entry = (Map.Entry) iterator.next();
+            String faultName = (String) entry.getKey();
+            Fault fault = (Fault) entry.getValue();
+            FaultDesc faultDesc = mapException(faultName, fault);
+
+            operationDesc.addFault(faultDesc);
+        }
+        return operationDesc;
+    }
+
+    private FaultDesc mapException(String faultName, Fault fault) throws DeploymentException {
+        Message message = fault.getMessage();
+        QName messageQName = message.getQName();
+        ExceptionMappingType exceptionMapping = (ExceptionMappingType) exceptionMap.get(messageQName);
+        if (exceptionMapping == null) {
+            throw new DeploymentException("No exception mapping for fault " + faultName + " and fault message " + messageQName + " for operation " + operationName);
+        }
+        String className = exceptionMapping.getExceptionType().getStringValue().trim();
+        //this is weird, but I can't figure out what it should be.
+        QName faultQName = new QName("", faultName);
+        Part part;
+        if (exceptionMapping.isSetWsdlMessagePartName()) {
+            //According to schema documentation, this will only be set when several headerfaults use the same message.
+            String headerFaultMessagePartName = exceptionMapping.getWsdlMessagePartName().getStringValue();
+            part = message.getPart(headerFaultMessagePartName);
+        } else {
+            part = (Part) message.getOrderedParts(null).iterator().next();
+        }
+        QName faultTypeQName = part.getElementName() == null ? part.getTypeName() : part.getElementName();
+        boolean isComplex = faultTypeQName != null && complexTypeMap.containsKey(faultTypeQName);
+        FaultDesc faultDesc = new FaultDesc(faultQName, className, faultTypeQName, isComplex);
+
+        //constructor parameters
+        if (exceptionMapping.isSetConstructorParameterOrder()) {
+            if (!isComplex) {
+                throw new DeploymentException("ConstructorParameterOrder can only be set for complex types, not " + faultTypeQName);
+            }
+            SchemaType complexType = (SchemaType) complexTypeMap.get(faultTypeQName);
+            Map elementMap = new HashMap();
+            SchemaProperty[] properties = complexType.getProperties();
+            for (int i = 0; i < properties.length; i++) {
+                SchemaProperty property = properties[i];
+                QName elementName = property.getName();
+                SchemaType elementType = property.getType();
+                QName elementTypeQName = elementType.getName();
+                elementMap.put(elementName.getLocalPart(), elementTypeQName);
+            }
+//                LocalElement[] elements = explicitGroup.getElementArray();
+//                for (int i = 0; i < elements.length; i++) {
+//                    LocalElement element = elements[i];
+//                    String elementName = element.getName();
+//                    QName elementType = element.getType();
+//                    elementMap.put(elementName, elementType);
+//                }
+            ArrayList parameterTypes = new ArrayList();
+            ConstructorParameterOrderType constructorParameterOrder = exceptionMapping.getConstructorParameterOrder();
+            for (int i = 0; i < constructorParameterOrder.getElementNameArray().length; i++) {
+                String elementName = constructorParameterOrder.getElementNameArray(i).getStringValue().trim();
+                QName elementType = (QName) elementMap.get(elementName);
+                String javaElementTypeName;
+                if (complexTypeMap.containsKey(elementType)) {
+                    String packageName = WSDescriptorParser.getPackageFromNamespace(elementType.getNamespaceURI(), mapping);
+                    javaElementTypeName = packageName + "." + elementType.getLocalPart();
+                } else {
+                    //TODO finish this
+                    if (elementType.getLocalPart().equals("String")) {
+                        javaElementTypeName = String.class.getName();
+                    } else {
+                        throw new DeploymentException("most simple exception constructor types not yet implemented");
+                    }
+                }
+                Class javaElementType;
+                try {
+                    javaElementType = ClassLoading.loadClass(javaElementTypeName, classLoader);
+                } catch (ClassNotFoundException e) {
+                    throw new DeploymentException("Could not load exception constructor parameter", e);
+                }
+                //todo faultTypeQName is speculative
+                //todo outheader might be true!
+                ParameterDesc parameterDesc = new ParameterDesc(faultTypeQName, ParameterDesc.OUT, elementType, javaElementType, false, false);
+                parameterTypes.add(parameterDesc);
+            }
+            faultDesc.setParameters(parameterTypes);
+        }
+        return faultDesc;
+    }
+
+    private void mapReturnType() throws DeploymentException {
+        QName returnType = null;
+        QName returnQName = null;
+        Class returnClass = null;
+
+        if (output == null) {
+            throw new DeploymentException("No output message, but a mapping for it for operation " + operationName);
+        }
+        WsdlReturnValueMappingType wsdlReturnValueMapping = methodMapping.getWsdlReturnValueMapping();
+        String returnClassName = wsdlReturnValueMapping.getMethodReturnValue().getStringValue().trim();
+        try {
+            returnClass = ClassLoading.loadClass(returnClassName, classLoader);
+        } catch (ClassNotFoundException e) {
+            throw new DeploymentException("Could not load return type for operation " + operationName, e);
+        }
+
+        QName wsdlMessageQName = wsdlReturnValueMapping.getWsdlMessage().getQNameValue();
+
+        if (!wsdlMessageQName.equals(output.getQName())) {
+            throw new DeploymentException("OutputMessage has QName: " + output.getQName() + " but mapping specifies: " + wsdlMessageQName + " for operation " + operationName);
+        }
+
+        if (wsdlReturnValueMapping.isSetWsdlMessagePartName()) {
+            String wsdlMessagePartName = wsdlReturnValueMapping.getWsdlMessagePartName().getStringValue().trim();
+            if (outParamNames.contains(wsdlMessagePartName)) {
+                throw new DeploymentException("output message part " + wsdlMessagePartName + " has both an INOUT or OUT mapping and a return value mapping for operation " + operationName);
+            }
+            Part part = output.getPart(wsdlMessagePartName);
+            returnQName = part.getElementName();
+            returnType = part.getTypeName();
+
+            outParamNames.add(wsdlMessagePartName);
+
+        } else {
+            //what does this mean????
+        }
+
+        operationDesc.setReturnQName(returnQName);
+        operationDesc.setReturnType(returnType);
+        operationDesc.setReturnClass(returnClass);
+    }
+
+    private ParameterDesc mapParameter(MethodParamPartsMappingType paramMapping, boolean wrappedElement) throws DeploymentException {
+        WsdlMessageMappingType wsdlMessageMappingType = paramMapping.getWsdlMessageMapping();
+        QName wsdlMessageQName = wsdlMessageMappingType.getWsdlMessage().getQNameValue();
+        String wsdlMessagePartName = wsdlMessageMappingType.getWsdlMessagePartName().getStringValue().trim();
+
+        String parameterMode = wsdlMessageMappingType.getParameterMode().getStringValue().trim();
+        byte mode = ParameterDesc.modeFromString(parameterMode);
+        boolean isInParam = mode == ParameterDesc.IN || mode == ParameterDesc.INOUT;
+        boolean isOutParam = mode == ParameterDesc.OUT || mode == ParameterDesc.INOUT;
+
+        if (isOutParam && output == null) {
+            throw new DeploymentException("Mapping for output parameter " + wsdlMessagePartName + " found, but no output message for operation " + operationName);
+        }
+        boolean isSoapHeader = wsdlMessageMappingType.isSetSoapHeader();
+        boolean inHeader = isSoapHeader && isInParam;
+        boolean outHeader = isSoapHeader && isOutParam;
+
+        Part part;
+        if (isInParam) {
+            if (!wsdlMessageQName.equals(input.getQName())) {
+                throw new DeploymentException("QName of input message: " + input.getQName() +
+                        " does not match mapping message QName: " + wsdlMessageQName + " for operation " + operationName);
+            }
+            part = input.getPart(wsdlMessagePartName);
+            if (part == null) {
+                throw new DeploymentException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in input message for operation " + operationName);
+            }
+            inParamNames.add(wsdlMessagePartName);
+            if (isOutParam) {
+                //inout, check that part of same name and type is in output message
+                Part outPart = output.getPart(wsdlMessagePartName);
+                if (outPart == null) {
+                    throw new DeploymentException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in output message for INOUT parameter of operation " + operationName);
+                }
+                if (!part.getName().equals(outPart.getName())) {
+                    throw new DeploymentException("Mismatched input part name: " + part.getName() + " and output part name: " + outPart.getName() + " for INOUT parameter for wsdlMessagePartName " + wsdlMessagePartName + " for operation " + operationName);
+                }
+                if (!(part.getElementName() == null ? outPart.getElementName() == null : part.getElementName().equals(outPart.getElementName()))) {
+                    throw new DeploymentException("Mismatched input part element name: " + part.getElementName() + " and output part element name: " + outPart.getElementName() + " for INOUT parameter for wsdlMessagePartName " + wsdlMessagePartName + " for operation " + operationName);
+                }
+                if (!(part.getTypeName() == null ? outPart.getTypeName() == null : part.getTypeName().equals(outPart.getTypeName()))) {
+                    throw new DeploymentException("Mismatched input part type name: " + part.getTypeName() + " and output part type name: " + outPart.getTypeName() + " for INOUT parameter for wsdlMessagePartName " + wsdlMessagePartName + " for operation " + operationName);
+                }
+                outParamNames.add(wsdlMessagePartName);
+            }
+        } else if (isOutParam) {
+            if (!wsdlMessageQName.equals(output.getQName())) {
+                throw new DeploymentException("QName of output message: " + output.getQName() +
+                        " does not match mapping message QName: " + wsdlMessageQName + " for operation " + operationName);
+            }
+            part = output.getPart(wsdlMessagePartName);
+            if (part == null) {
+                throw new DeploymentException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in output message for operation " + operationName);
+            }
+            outParamNames.add(wsdlMessagePartName);
+        } else {
+            throw new AssertionError("a param mapping has to be IN or OUT or INOUT");
+        }
+
+        //TODO this makes little sense but may be correct, see comments in axis Parameter class
+        //the part name qname is really odd.
+        QName partQName = wrappedElement ? part.getElementName() : new QName("", part.getName());
+        QName partTypeQName = part.getTypeName();
+
+        //use complexTypeMap
+        boolean isComplexType = complexTypeMap.containsKey(partTypeQName);
+        String paramJavaTypeName = paramMapping.getParamType().getStringValue().trim();
+        boolean isInOnly = mode == ParameterDesc.IN;
+        Class actualParamJavaType = WSDescriptorParser.getHolderType(paramJavaTypeName, isInOnly, partTypeQName, isComplexType, mapping, classLoader);
+
+        ParameterDesc parameterDesc = new ParameterDesc(partQName, mode, partTypeQName, actualParamJavaType, inHeader, outHeader);
+        return parameterDesc;
+    }
+}

Added: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/LightweightOperationDescBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/LightweightOperationDescBuilder.java?view=auto&rev=155737
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/LightweightOperationDescBuilder.java (added)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/LightweightOperationDescBuilder.java Mon Feb 28 18:36:44 2005
@@ -0,0 +1,133 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.axis.builder;
+
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.wsdl.Part;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Operation;
+import javax.wsdl.Message;
+import javax.wsdl.extensions.soap.SOAPOperation;
+
+import org.apache.geronimo.axis.client.OperationInfo;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.axis.soap.SOAPConstants;
+import org.apache.axis.description.OperationDesc;
+import org.apache.axis.description.ParameterDesc;
+import org.apache.axis.constants.Style;
+import org.apache.axis.constants.Use;
+import org.objectweb.asm.Type;
+
+public class LightweightOperationDescBuilder extends OperationDescBuilder {
+
+    private final Method method;
+
+    public LightweightOperationDescBuilder(BindingOperation bindingOperation, Method method) throws DeploymentException{
+        super(bindingOperation);
+        if (bindingOperation == null) {
+            throw new DeploymentException("No BindingOperation supplied for method " + method.getName());
+        }
+
+        this.method = method;
+
+        operationDesc.setName(operationName);
+        operationDesc.setStyle(Style.RPC);
+        operationDesc.setUse(Use.ENCODED);
+    }
+
+    public OperationInfo buildOperationInfo(SOAPConstants soapVersion) throws DeploymentException {
+        buildOperationDesc();
+        String soapActionURI = soapOperation.getSoapActionURI();
+        boolean usesSOAPAction = (soapActionURI != null);
+        QName operationQName = new QName("", operation.getName());
+
+        String methodName = method.getName();
+        String methodDesc = Type.getMethodDescriptor(method);
+
+
+        OperationInfo operationInfo = new OperationInfo(operationDesc, usesSOAPAction, soapActionURI, soapVersion, operationQName, methodName, methodDesc);
+        return operationInfo;
+    }
+
+    public OperationDesc buildOperationDesc() throws DeploymentException {
+        if (built) {
+            return operationDesc;
+        }
+
+        built = true;
+
+        //section 7.3.2, we don't have to look at parameter ordering.
+        //unless it turns out we have to validate it.
+//        List order = operation.getParameterOrdering();
+
+        // Verify we have the right number of args for this method
+        Class[] methodParamTypes = method.getParameterTypes();
+        List inputParts = input.getOrderedParts(null);
+        if (methodParamTypes.length != inputParts.size()) {
+            throw new DeploymentException("mismatch in parameter counts: method has " + methodParamTypes.length + " whereas the input message has " + inputParts.size());
+        }
+
+        // Map the input parts to method args
+        int i = 0;
+        for (Iterator parts = inputParts.iterator(); parts.hasNext();) {
+            Part part = (Part) parts.next();
+            String partName = part.getName();
+            QName name = new QName("", partName);
+            byte mode = ParameterDesc.IN;
+            QName typeQName = part.getTypeName() == null ? part.getElementName() : part.getTypeName();
+            Class javaClass = methodParamTypes[i++];
+            //lightweight mapping has no parts in headers, so inHeader and outHeader are false
+            ParameterDesc parameter = new ParameterDesc(name, mode, typeQName, javaClass, false, false);
+            operationDesc.addParameter(parameter);
+        }
+
+        // Can't have multiple return values
+        if (output != null && output.getParts().size() > 1) {
+            throw new DeploymentException("Lightweight mapping has at most one part in the (optional) output message, not: " + output.getParts().size());
+        }
+
+        // Map the return message, if there is one
+        if (output != null && output.getParts().size() == 1) {
+            // Set the element name
+            operationDesc.setReturnQName(output.getQName());
+
+            // Set the element type
+            Part part = (Part) output.getParts().values().iterator().next();
+            QName returnType = part.getTypeName() == null ? part.getElementName() : part.getTypeName();
+            operationDesc.setReturnType(returnType);
+
+            // Set the java class
+            operationDesc.setReturnClass(method.getReturnType());
+        }
+
+        //TODO add faults
+//        TFault[] faults = tOperation.getFaultArray();
+//        for (int i = 0; i < faults.length; i++) {
+//            TFault fault = faults[i];
+//            QName faultQName = new QName("", fault.getName());
+//            String className = ;
+//            QName faultTypeQName = ;
+//            boolean isComplex = ;
+//            FaultDesc faultDesc = new FaultDesc(faultQName, className, faultTypeQName, isComplex)
+//        }
+        return operationDesc;
+    }
+}

Added: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/OperationDescBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/OperationDescBuilder.java?view=auto&rev=155737
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/OperationDescBuilder.java (added)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/OperationDescBuilder.java Mon Feb 28 18:36:44 2005
@@ -0,0 +1,53 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.axis.builder;
+
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Operation;
+import javax.wsdl.Message;
+import javax.wsdl.extensions.soap.SOAPOperation;
+
+import org.apache.geronimo.axis.client.OperationInfo;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.axis.soap.SOAPConstants;
+import org.apache.axis.description.OperationDesc;
+
+public abstract class OperationDescBuilder {
+    protected final OperationDesc operationDesc;
+    protected final BindingOperation bindingOperation;
+    protected final Operation operation;
+    protected final String operationName;
+    protected final Message input;
+    protected final Message output;
+    protected final SOAPOperation soapOperation;
+    protected boolean built;
+
+    public OperationDescBuilder(BindingOperation bindingOperation) throws DeploymentException {
+        this.bindingOperation = bindingOperation;
+        this.operation = bindingOperation.getOperation();
+        this.soapOperation = (SOAPOperation) WSDescriptorParser.getExtensibilityElement(SOAPOperation.class, bindingOperation.getExtensibilityElements());
+
+        operationDesc = new OperationDesc();
+        output = operation.getOutput() == null ? null : operation.getOutput().getMessage();
+        operationName = operation.getName();
+        input = operation.getInput().getMessage();
+    }
+
+    public abstract OperationInfo buildOperationInfo(SOAPConstants soapVersion) throws DeploymentException;
+
+    public abstract OperationDesc buildOperationDesc() throws DeploymentException;
+}

Added: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/TypeDescBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/TypeDescBuilder.java?view=auto&rev=155737
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/TypeDescBuilder.java (added)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/TypeDescBuilder.java Mon Feb 28 18:36:44 2005
@@ -0,0 +1,101 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.axis.builder;
+
+import java.beans.PropertyDescriptor;
+import java.beans.Introspector;
+import java.beans.IntrospectionException;
+import java.util.Map;
+import java.util.HashMap;
+import javax.xml.namespace.QName;
+
+import org.apache.axis.description.TypeDesc;
+import org.apache.axis.description.FieldDesc;
+import org.apache.axis.description.AttributeDesc;
+import org.apache.axis.description.ElementDesc;
+import org.apache.geronimo.xbeans.j2ee.JavaXmlTypeMappingType;
+import org.apache.geronimo.xbeans.j2ee.VariableMappingType;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.xmlbeans.SchemaType;
+
+public class TypeDescBuilder {
+    public static TypeDesc getTypeDescriptor(Class javaClass, QName typeQName, JavaXmlTypeMappingType javaXmlTypeMapping, SchemaType schemaType) throws DeploymentException {
+        boolean isRestriction = schemaType.getDerivationType() == SchemaType.DT_RESTRICTION;
+        TypeDesc typeDesc = new TypeDesc(javaClass, !isRestriction);
+        //TODO typeQName may be a 'anonymous" QName like construct.  Is this what axis expects?
+        typeDesc.setXmlType(typeQName);
+        VariableMappingType[] variableMappings = javaXmlTypeMapping.getVariableMappingArray();
+        FieldDesc[] fields = new FieldDesc[variableMappings.length];
+
+        PropertyDescriptor[] propertyDescriptors = new PropertyDescriptor[0];
+        try {
+            propertyDescriptors = Introspector.getBeanInfo(javaClass).getPropertyDescriptors();
+        } catch (IntrospectionException e) {
+            throw new DeploymentException("Class " + javaClass + " is not a valid javabean", e);
+        }
+        Map properties = new HashMap();
+        for (int i = 0; i < propertyDescriptors.length; i++) {
+            PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
+            properties.put(propertyDescriptor.getName(), propertyDescriptor.getPropertyType());
+        }
+        for (int i = 0; i < variableMappings.length; i++) {
+            VariableMappingType variableMapping = variableMappings[i];
+            String fieldName = variableMapping.getJavaVariableName().getStringValue().trim();
+
+            if (variableMapping.isSetXmlAttributeName()) {
+                AttributeDesc attributeDesc = new AttributeDesc();
+                //setting attribute name sets the xmlName with "" namespace, so don't do it
+//                attributeDesc.setAttributeName(fieldName);
+                attributeDesc.setFieldName(fieldName);
+                Class javaType = (Class) properties.get(fieldName);
+                if (javaType == null) {
+                    throw new DeploymentException("field name " + fieldName + " not found in " + properties);
+                }
+                attributeDesc.setJavaType(javaType);
+                //TODO correct namespace???
+                String namespace = "";
+                QName xmlName = new QName(namespace, variableMapping.getXmlAttributeName().getStringValue().trim());
+                attributeDesc.setXmlName(xmlName);
+                QName xmlType = schemaType.getName();
+                attributeDesc.setXmlType(xmlType);
+                fields[i] = attributeDesc;
+            } else {
+                ElementDesc elementDesc = new ElementDesc();
+                elementDesc.setFieldName(fieldName);
+                Class javaType = (Class) properties.get(fieldName);
+                if (javaType == null) {
+                    throw new DeploymentException("field name " + fieldName + " not found in " + properties);
+                }
+                elementDesc.setJavaType(javaType);
+                //TODO correct namespace???
+                String namespace = "";
+                QName xmlName = new QName(namespace, variableMapping.getXmlElementName().getStringValue().trim());
+                elementDesc.setXmlName(xmlName);
+                QName xmlType = schemaType.getName();
+                elementDesc.setXmlType(xmlType);
+                //TODO figure out how to find these:
+//                elementDesc.setArrayType(null);
+//                elementDesc.setMinOccurs(0);
+//                elementDesc.setMaxOccurs(0);
+//                elementDesc.setNillable(false);
+                fields[i] = elementDesc;
+            }
+        }
+        typeDesc.setFields(fields);
+        return typeDesc;
+    }
+}



Mime
View raw message