geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r160071 - in geronimo/trunk/modules/axis-builder/src: java/org/apache/geronimo/axis/builder/ test-resources/schema/ test/org/apache/geronimo/axis/builder/
Date Mon, 04 Apr 2005 17:53:59 GMT
Author: djencks
Date: Mon Apr  4 10:53:58 2005
New Revision: 160071

URL: http://svn.apache.org/viewcvs?view=rev&rev=160071
Log:
fix a few bugs, mostly regarding confusing elements and their type

Added:
    geronimo/trunk/modules/axis-builder/src/test-resources/schema/schema4.xsd
Modified:
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java
    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/WSDescriptorParser.java
    geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ParsingTest.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=160070&r2=160071
==============================================================================
--- 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 Apr  4 10:53:58 2005
@@ -235,6 +235,7 @@
         Map exceptionMap = WSDescriptorParser.getExceptionMap(mapping);
         Map schemaTypeKeyToSchemaTypeMap = WSDescriptorParser.buildSchemaTypeKeyToSchemaTypeMap(definition);
         Map complexTypeMap = WSDescriptorParser.getComplexTypesInWsdl(schemaTypeKeyToSchemaTypeMap);
+        Map elementMap = WSDescriptorParser.getElementToTypeMap(schemaTypeKeyToSchemaTypeMap);
 
         Map wsdlPortMap = service.getPorts();
         for (Iterator iterator = wsdlPortMap.entrySet().iterator(); iterator.hasNext();)
{
@@ -260,7 +261,7 @@
             if (endpointMappings.length == 0) {
                 doLightweightMapping(service.getQName(), portType, mapping, classLoader,
context, module, operations, binding, portStyle, soapVersion, operationInfos, schemaTypeKeyToSchemaTypeMap,
portName, serviceImpl, location, handlerInfos, seiPortNameToFactoryMap, seiClassNameToFactoryMap,
credentialsName);
             } else {
-                doHeavyweightMapping(service.getQName(), portType, endpointMappings, classLoader,
context, module, operations, binding, portStyle, soapVersion, exceptionMap, complexTypeMap,
mapping, operationInfos, schemaTypeKeyToSchemaTypeMap, portName, serviceImpl, location, handlerInfos,
seiPortNameToFactoryMap, seiClassNameToFactoryMap, credentialsName);
+                doHeavyweightMapping(service.getQName(), portType, endpointMappings, classLoader,
context, module, operations, binding, portStyle, soapVersion, exceptionMap, complexTypeMap,
elementMap, mapping, operationInfos, schemaTypeKeyToSchemaTypeMap, portName, serviceImpl,
location, handlerInfos, seiPortNameToFactoryMap, seiClassNameToFactoryMap, credentialsName);
             }
         }
     }
@@ -302,7 +303,7 @@
         return location;
     }
 
-    private void doHeavyweightMapping(QName serviceName, PortType portType, ServiceEndpointInterfaceMappingType[]
endpointMappings, ClassLoader classLoader, DeploymentContext context, Module module, List
operations, Binding binding, Style portStyle, SOAPConstants soapVersion, Map exceptionMap,
Map complexTypeMap, JavaWsdlMappingType mapping, OperationInfo[] operationInfos, Map schemaTypeKeyToSchemaTypeMap,
String portName, Object serviceImpl, URL location, List handlerInfos, Map seiPortNameToFactoryMap,
Map seiClassNameToFactoryMap, String credentialsName) throws DeploymentException {
+    private void doHeavyweightMapping(QName serviceName, PortType portType, ServiceEndpointInterfaceMappingType[]
endpointMappings, ClassLoader classLoader, DeploymentContext context, Module module, List
operations, Binding binding, Style portStyle, SOAPConstants soapVersion, Map exceptionMap,
Map complexTypeMap, Map elementMap, JavaWsdlMappingType mapping, OperationInfo[] operationInfos,
Map schemaTypeKeyToSchemaTypeMap, String portName, Object serviceImpl, URL location, List
handlerInfos, Map seiPortNameToFactoryMap, Map seiClassNameToFactoryMap, String credentialsName)
throws DeploymentException {
         Class serviceEndpointInterface;
         SEIFactory seiFactory;
         //complete jaxrpc mapping file supplied
@@ -321,9 +322,23 @@
         for (Iterator ops = operations.iterator(); ops.hasNext();) {
             Operation operation = (Operation) ops.next();
             String operationName = operation.getName();
-            BindingOperation bindingOperation = binding.getBindingOperation(operationName,
operation.getInput().getName(), operation.getOutput() == null ? null : operation.getOutput().getName());
+            //the obvious method seems to be buggy
+//            BindingOperation bindingOperation = binding.getBindingOperation(operationName,
operation.getInput().getName(), operation.getOutput() == null ? null : operation.getOutput().getName());
+            BindingOperation bindingOperation = null;
+            List bops = binding.getBindingOperations();
+            for (Iterator iterator = bops.iterator(); iterator.hasNext();) {
+                BindingOperation bindingOperation1 = (BindingOperation) iterator.next();
+                if (bindingOperation1.getOperation().equals(operation)) {
+                    bindingOperation = bindingOperation1;
+                    break;
+                }
+            }
+            if (bindingOperation == null) {
+                throw new DeploymentException("No BindingOperation for operation: " + operationName
+ ", input: " + operation.getInput().getName() + ", output: " + (operation.getOutput() ==
null ? "<none>" : operation.getOutput().getName()));
+            }
             ServiceEndpointMethodMappingType methodMapping = WSDescriptorParser.getMethodMappingForOperation(operationName,
methodMappings);
-            OperationInfo operationInfo = buildOperationInfoHeavyweight(methodMapping, bindingOperation,
portStyle, soapVersion, exceptionMap, complexTypeMap, mapping, classLoader, enhancedServiceEndpointClass);
+            HeavyweightOperationDescBuilder operationDescBuilder = new HeavyweightOperationDescBuilder(bindingOperation,
mapping, methodMapping, portStyle, exceptionMap, complexTypeMap, elementMap, classLoader,
enhancedServiceEndpointClass);
+            OperationInfo operationInfo = operationDescBuilder.buildOperationInfo(soapVersion);
             operationInfos[i++] = operationInfo;
         }
         JavaXmlTypeMappingType[] javaXmlTypeMappings = mapping.getJavaXmlTypeMappingArray();
@@ -514,11 +529,6 @@
 
     public OperationInfo buildOperationInfoLightweight(Method method, BindingOperation bindingOperation,
Style defaultStyle, SOAPConstants soapVersion) throws DeploymentException {
         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, Class serviceEndpointInterface)
throws DeploymentException {
-        HeavyweightOperationDescBuilder operationDescBuilder = new HeavyweightOperationDescBuilder(bindingOperation,
mapping, methodMapping, defaultStyle, exceptionMap, complexTypeMap, classLoader, serviceEndpointInterface);
         return operationDescBuilder.buildOperationInfo(soapVersion);
     }
 

Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java?view=diff&r1=160070&r2=160071
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java
Mon Apr  4 10:53:58 2005
@@ -16,23 +16,6 @@
  */
 package org.apache.geronimo.axis.builder;
 
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
-import java.util.jar.JarFile;
-import java.io.Serializable;
-import javax.wsdl.*;
-import javax.wsdl.extensions.soap.SOAPAddress;
-import javax.wsdl.extensions.soap.SOAPBinding;
-import javax.wsdl.extensions.soap.SOAPBody;
-import javax.xml.namespace.QName;
-import javax.xml.rpc.handler.HandlerInfo;
-
 import org.apache.axis.constants.Style;
 import org.apache.axis.constants.Use;
 import org.apache.axis.description.JavaServiceDesc;
@@ -42,18 +25,27 @@
 import org.apache.axis.encoding.TypeMapping;
 import org.apache.axis.encoding.TypeMappingRegistryImpl;
 import org.apache.axis.encoding.ser.*;
+import org.apache.geronimo.axis.server.ReadOnlyServiceDesc;
+import org.apache.geronimo.axis.server.ServiceInfo;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.kernel.ClassLoading;
-import org.apache.geronimo.xbeans.j2ee.JavaXmlTypeMappingType;
-import org.apache.geronimo.xbeans.j2ee.ServiceEndpointMethodMappingType;
-import org.apache.geronimo.xbeans.j2ee.PortComponentHandlerType;
-import org.apache.geronimo.xbeans.j2ee.ParamValueType;
-import org.apache.geronimo.xbeans.j2ee.XsdQNameType;
-import org.apache.geronimo.axis.server.ReadOnlyServiceDesc;
-import org.apache.geronimo.axis.server.ServiceInfo;
+import org.apache.geronimo.xbeans.j2ee.*;
 import org.apache.xmlbeans.SchemaType;
 
+import javax.wsdl.*;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.wsdl.extensions.soap.SOAPBody;
+import javax.xml.namespace.QName;
+import javax.xml.rpc.handler.HandlerInfo;
+import java.lang.String;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.*;
+import java.util.jar.JarFile;
+
 /**
  * @version $Rev$ $Date$
  */
@@ -158,7 +150,7 @@
         Map exceptionMap = WSDescriptorParser.getExceptionMap(portInfo.getJavaWsdlMapping());
         Map schemaTypeKeyToSchemaTypeMap = WSDescriptorParser.buildSchemaTypeKeyToSchemaTypeMap(portInfo.getDefinition());
         Map complexTypeMap = WSDescriptorParser.getComplexTypesInWsdl(schemaTypeKeyToSchemaTypeMap);
-
+        Map elementMap = WSDescriptorParser.getElementToTypeMap(schemaTypeKeyToSchemaTypeMap);
 
         JavaServiceDesc serviceDesc = new JavaServiceDesc();
 
@@ -187,7 +179,7 @@
             validateLightweightMapping(portInfo.getDefinition());
         }
 
-        buildOperations(binding, serviceEndpointInterface, isLightweight, portInfo, exceptionMap,
complexTypeMap, classLoader, serviceDesc);
+        buildOperations(binding, serviceEndpointInterface, isLightweight, portInfo, exceptionMap,
complexTypeMap, elementMap, classLoader, serviceDesc);
 
         TypeMappingRegistryImpl tmr = new TypeMappingRegistryImpl();
         tmr.doRegisterFromVersion("1.3");
@@ -304,7 +296,7 @@
         }
     }
 
-    private static void buildOperations(Binding binding, Class serviceEndpointInterface,
boolean lightweight, PortInfo portInfo, Map exceptionMap, Map complexTypeMap, ClassLoader
classLoader, JavaServiceDesc serviceDesc) throws DeploymentException {
+    private static void buildOperations(Binding binding, Class serviceEndpointInterface,
boolean lightweight, PortInfo portInfo, Map exceptionMap, Map complexTypeMap, Map elementMap,
ClassLoader classLoader, JavaServiceDesc serviceDesc) throws DeploymentException {
         List bindingOperations = binding.getBindingOperations();
         for (int i = 0; i < bindingOperations.size(); i++) {
             BindingOperation bindingOperation = (BindingOperation) bindingOperations.get(i);
@@ -317,7 +309,7 @@
                 String operationName = bindingOperation.getOperation().getName();
                 ServiceEndpointMethodMappingType[] methodMappings = portInfo.getServiceEndpointInterfaceMapping().getServiceEndpointMethodMappingArray();
                 ServiceEndpointMethodMappingType methodMapping = WSDescriptorParser.getMethodMappingForOperation(operationName,
methodMappings);
-                operationDescBuilder = new HeavyweightOperationDescBuilder(bindingOperation,
portInfo.getJavaWsdlMapping(), methodMapping, Style.RPC, exceptionMap, complexTypeMap, classLoader,
serviceEndpointInterface);
+                operationDescBuilder = new HeavyweightOperationDescBuilder(bindingOperation,
portInfo.getJavaWsdlMapping(), methodMapping, Style.RPC, exceptionMap, complexTypeMap, elementMap,
classLoader, serviceEndpointInterface);
             }
 
             serviceDesc.addOperationDesc(operationDescBuilder.buildOperationDesc());

Modified: 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=diff&r1=160070&r2=160071
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java
Mon Apr  4 10:53:58 2005
@@ -71,6 +71,7 @@
     private final Style defaultStyle;
     private final Map exceptionMap;
     private final Map complexTypeMap;
+    private final Map elementMap;
     private final ClassLoader classLoader;
 
     /* Keep track of in and out parameter names so we can verify that
@@ -80,13 +81,14 @@
     private final Set outParamNames = new HashSet();
     private final Class serviceEndpointInterface;
 
-    public HeavyweightOperationDescBuilder(BindingOperation bindingOperation, JavaWsdlMappingType
mapping, ServiceEndpointMethodMappingType methodMapping, Style defaultStyle, Map exceptionMap,
Map complexTypeMap, ClassLoader classLoader, Class serviceEndpointInterface) throws DeploymentException
{
+    public HeavyweightOperationDescBuilder(BindingOperation bindingOperation, JavaWsdlMappingType
mapping, ServiceEndpointMethodMappingType methodMapping, Style defaultStyle, Map exceptionMap,
Map complexTypeMap, Map elementMap, ClassLoader classLoader, Class serviceEndpointInterface)
throws DeploymentException {
         super(bindingOperation);
         this.mapping = mapping;
         this.methodMapping = methodMapping;
         this.defaultStyle = defaultStyle;
         this.exceptionMap = exceptionMap;
         this.complexTypeMap = complexTypeMap;
+        this.elementMap = elementMap;
         this.classLoader = classLoader;
         this.serviceEndpointInterface = serviceEndpointInterface;
         BindingInput bindingInput = bindingOperation.getBindingInput();
@@ -123,7 +125,7 @@
         }
         built = true;
 
-        operationDesc.setName( operationName );
+        operationDesc.setName(operationName);
         
         // Set to 'document' or 'rpc'
         Style style = Style.getStyle(soapOperation.getStyle(), defaultStyle);
@@ -176,12 +178,12 @@
             String args = "(";
             for (int i = 0; i < paramTypes.length; i++) {
                 args += paramTypes[i].getName();
-                if (i < paramTypes.length - 1){
+                if (i < paramTypes.length - 1) {
                     args += ",";
                 }
             }
             args += ")";
-            
+
             throw new DeploymentException("Mapping references non-existent method in service-endpoint:
" + methodName + args);
         }
 
@@ -255,8 +257,20 @@
         } else {
             part = (Part) message.getOrderedParts(null).iterator().next();
         }
-        QName faultTypeQName = part.getElementName() == null ? part.getTypeName() : part.getElementName();
-        boolean isComplex = faultTypeQName != null && complexTypeMap.containsKey(faultTypeQName);
+        QName faultTypeQName;// = part.getElementName() == null ? part.getTypeName() : part.getElementName();
+        if (part.getElementName() == null) {
+            faultTypeQName = part.getTypeName();
+            if (faultTypeQName == null) {
+                throw new DeploymentException("Neither type nor element name supplied for
part: " + part);
+            }
+        } else {
+            faultTypeQName = (QName) elementMap.get(part.getElementName());
+            if (faultTypeQName == null) {
+                throw new DeploymentException("Can not find type for: element: " + part.getElementName()
+ ", known elements: " + elementMap);
+            }
+        }
+        SchemaType complexType = (SchemaType) complexTypeMap.get(faultTypeQName);
+        boolean isComplex = complexType != null;
         FaultDesc faultDesc = new FaultDesc(faultQName, className, faultTypeQName, isComplex);
 
         //constructor parameters
@@ -264,7 +278,6 @@
             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++) {
@@ -295,10 +308,10 @@
                     } catch (ClassNotFoundException e) {
                         throw new DeploymentException("Could not load exception constructor
parameter", e);
                     }
-                } else if (qnameToClassMap.containsKey(elementType)){
+                } else if (qnameToClassMap.containsKey(elementType)) {
                     javaElementType = (Class) qnameToClassMap.get(elementType);
                 } else {
-                    throw new DeploymentException("Unknown type: " +  elementType);
+                    throw new DeploymentException("Unknown type: " + elementType);
                 }
                 //todo faultTypeQName is speculative
                 //todo outheader might be true!
@@ -401,7 +414,7 @@
             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);

Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/WSDescriptorParser.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/WSDescriptorParser.java?view=diff&r1=160070&r2=160071
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/WSDescriptorParser.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/WSDescriptorParser.java
Mon Apr  4 10:53:58 2005
@@ -521,6 +521,21 @@
         return complexTypeMap;
     }
 
+    public static Map getElementToTypeMap(Map schemaTypeKeyToSchemaTypeMap) {
+        Map elementToTypeMap = new HashMap();
+        for (Iterator iterator = schemaTypeKeyToSchemaTypeMap.entrySet().iterator(); iterator.hasNext();)
{
+            Map.Entry entry = (Map.Entry) iterator.next();
+            SchemaTypeKey key = (SchemaTypeKey) entry.getKey();
+            if (key.isElement()) {
+                QName elementQName = key.getqName();
+                SchemaType schemaType = (SchemaType) entry.getValue();
+                QName typeQName = schemaType.getName();
+                elementToTypeMap.put(elementQName, typeQName);
+            }
+        }
+        return elementToTypeMap;
+    }
+
     public static Map getExceptionMap(JavaWsdlMappingType mapping) {
         Map exceptionMap = new HashMap();
         if (mapping != null) {

Added: geronimo/trunk/modules/axis-builder/src/test-resources/schema/schema4.xsd
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/test-resources/schema/schema4.xsd?view=auto&rev=160071
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/test-resources/schema/schema4.xsd (added)
+++ geronimo/trunk/modules/axis-builder/src/test-resources/schema/schema4.xsd Mon Apr  4 10:53:58
2005
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<schema targetNamespace="elementtest"
+    xmlns:elementtest="elementtest"
+    xmlns="http://www.w3.org/2001/XMLSchema">
+    <element name="teststring" type="elementtest:stringtest"/>
+    <complexType name="stringtest">
+        <sequence>
+            <element name="value" type="string"/>
+        </sequence>
+    </complexType>
+</schema>

Modified: geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ParsingTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ParsingTest.java?view=diff&r1=160070&r2=160071
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ParsingTest.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ParsingTest.java
Mon Apr  4 10:53:58 2005
@@ -84,4 +84,15 @@
         return map;
     }
 
+    public void testElementToTypeMapping() throws Exception {
+        File schema1 = new File(basedir, "src/test-resources/schema/schema4.xsd");
+        System.out.println("SCHEMA 4");
+        Map map = parse(schema1);
+        assertEquals(3, map.size());
+        Map elements = WSDescriptorParser.getElementToTypeMap(map);
+        System.out.println("ELEMENT MAP");
+        System.out.println(elements);
+        assertEquals(1, elements.size());
+    }
+
 }



Mime
View raw message