axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r439165 - in /webservices/axis2/trunk/java/modules: adb/src/org/apache/axis2/databinding/utils/ integration/test/org/apache/axis2/rpc/ java2wsdl/src/org/apache/ws/java2wsdl/
Date Fri, 01 Sep 2006 04:13:44 GMT
Author: deepal
Date: Thu Aug 31 21:13:43 2006
New Revision: 439165

URL: http://svn.apache.org/viewvc?rev=439165&view=rev
Log:
- fixed nil handling in RPC Message receiver

Modified:
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
    webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java

Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java?rev=439165&r1=439164&r2=439165&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
(original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
Thu Aug 31 21:13:43 2006
@@ -92,12 +92,12 @@
                 }
                 if (SimpleTypeMapper.isSimpleType(ptype)) {
                     Object value = propDesc.getReadMethod().invoke(beanObject,
-                            (Object[]) null);
+                            null);
                     object.add(new QName(beanName.getNamespaceURI(), propDesc.getName(),
beanName.getPrefix()));
                     object.add(value == null ? null : SimpleTypeMapper.getStringValue(value));
                 } else if (ptype.isArray()) {
                     Object value [] = (Object[]) propDesc.getReadMethod().invoke(beanObject,
-                            (Object[]) null);
+                            null);
                     if (SimpleTypeMapper.isSimpleType(ptype.getComponentType())) {
                         for (int j = 0; j < value.length; j++) {
                             Object o = value[j];
@@ -114,7 +114,7 @@
 
                 } else if (SimpleTypeMapper.isArrayList(ptype)) {
                     Object value = propDesc.getReadMethod().invoke(beanObject,
-                            (Object[]) null);
+                            null);
                     ArrayList objList = (ArrayList) value;
                     if (objList != null && objList.size() > 0) {
                         //this was given error , when the array.size = 0
@@ -135,7 +135,7 @@
                 } else {
                     object.add(new QName(propDesc.getName()));
                     Object value = propDesc.getReadMethod().invoke(beanObject,
-                            (Object[]) null);
+                            null);
                     object.add(value);
                 }
             }
@@ -404,8 +404,9 @@
                     done = false;
                     break;
                 }
-                valueList.add(processObject(omElement, arrayClassType,
-                        helper));
+                Object o = processObject(omElement, arrayClassType,
+                        helper);
+                valueList.add(o);
             }
             retObjs[count] = ConverterUtil.convertToArray(arrayClassType,
                     valueList);
@@ -447,6 +448,11 @@
                     return helper.processRef(classType, ref);
                 }
             } else {
+                OMAttribute attribute = omElement.getAttribute(
+                        new QName("http://www.w3.org/2001/XMLSchema-instance", "nil", "xsi"));
+                if (attribute != null) {
+                    return null;
+                }
                 if (SimpleTypeMapper.isSimpleType(classType)) {
                     return SimpleTypeMapper.getSimpleTypeObject(classType, omElement);
                 } else if (SimpleTypeMapper.isArrayList(classType)) {
@@ -465,6 +471,8 @@
         for (int i = 0; i < args.length; i++) {
             Object arg = args[i];
             if (arg == null) {
+                objects.add("item" + i);
+                objects.add(arg);
                 continue;
             }
             //todo if the request parameter has name other than argi (0<i<n) , there
should be a

Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java?rev=439165&r1=439164&r2=439165&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java
(original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java
Thu Aug 31 21:13:43 2006
@@ -1,48 +1,19 @@
 package org.apache.axis2.databinding.utils;
 
+import org.apache.axiom.attachments.ByteArrayDataSource;
+import org.apache.axiom.attachments.utils.IOUtils;
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.attachments.ByteArrayDataSource;
-import org.apache.axiom.attachments.utils.IOUtils;
-import org.apache.axis2.databinding.types.Day;
-import org.apache.axis2.databinding.types.Duration;
-import org.apache.axis2.databinding.types.Entities;
-import org.apache.axis2.databinding.types.Entity;
-import org.apache.axis2.databinding.types.HexBinary;
-import org.apache.axis2.databinding.types.IDRef;
-import org.apache.axis2.databinding.types.IDRefs;
-import org.apache.axis2.databinding.types.Id;
-import org.apache.axis2.databinding.types.Language;
-import org.apache.axis2.databinding.types.Month;
-import org.apache.axis2.databinding.types.MonthDay;
-import org.apache.axis2.databinding.types.NCName;
-import org.apache.axis2.databinding.types.NMToken;
-import org.apache.axis2.databinding.types.NMTokens;
-import org.apache.axis2.databinding.types.Name;
-import org.apache.axis2.databinding.types.NegativeInteger;
-import org.apache.axis2.databinding.types.NonNegativeInteger;
-import org.apache.axis2.databinding.types.NonPositiveInteger;
-import org.apache.axis2.databinding.types.NormalizedString;
-import org.apache.axis2.databinding.types.Notation;
-import org.apache.axis2.databinding.types.PositiveInteger;
-import org.apache.axis2.databinding.types.Time;
-import org.apache.axis2.databinding.types.Token;
-import org.apache.axis2.databinding.types.URI;
-import org.apache.axis2.databinding.types.UnsignedByte;
-import org.apache.axis2.databinding.types.UnsignedInt;
-import org.apache.axis2.databinding.types.UnsignedLong;
-import org.apache.axis2.databinding.types.UnsignedShort;
-import org.apache.axis2.databinding.types.Year;
-import org.apache.axis2.databinding.types.YearMonth;
+import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axis2.databinding.i18n.ADBMessages;
+import org.apache.axis2.databinding.types.*;
 import org.apache.axis2.util.Base64;
 
+import javax.activation.DataHandler;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
-import javax.activation.DataHandler;
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.lang.reflect.Array;
@@ -51,12 +22,7 @@
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.TimeZone;
+import java.util.*;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -102,7 +68,7 @@
     }
 
     public static String convertToString(byte i) {
-        return ((int)i)+"";
+        return ((int) i) + "";
     }
 
     public static String convertToString(char i) {
@@ -124,7 +90,7 @@
         synchronized (calendar) {
             if (calendar.get(Calendar.ERA) == GregorianCalendar.BC) {
                 buf.append("-");
-                calendar.setTime((Date)value);
+                calendar.setTime((Date) value);
                 calendar.set(Calendar.ERA, GregorianCalendar.AD);
                 value = calendar.getTime();
             }
@@ -168,6 +134,7 @@
     public static String convertToString(Time o) {
         return o.toString();
     }
+
     public static String convertToString(Byte o) {
         return o.toString();
     }
@@ -175,6 +142,7 @@
     public static String convertToString(BigInteger o) {
         return o.toString();
     }
+
     public static String convertToString(Integer o) {
         return o.toString();
     }
@@ -243,9 +211,9 @@
     }
 
     public static double convertToDouble(String s) {
-        if (POSITIVE_INFINITY.equals(s)){
+        if (POSITIVE_INFINITY.equals(s)) {
             return Double.POSITIVE_INFINITY;
-        }else if (NEGATIVE_INFINITY.equals(s)){
+        } else if (NEGATIVE_INFINITY.equals(s)) {
             return Double.NEGATIVE_INFINITY;
         }
         return Double.parseDouble(s);
@@ -256,9 +224,9 @@
     }
 
     public static float convertToFloat(String s) {
-        if (POSITIVE_INFINITY.equals(s)){
+        if (POSITIVE_INFINITY.equals(s)) {
             return Float.POSITIVE_INFINITY;
-        }else if (NEGATIVE_INFINITY.equals(s)){
+        } else if (NEGATIVE_INFINITY.equals(s)) {
             return Float.NEGATIVE_INFINITY;
         }
         return Float.parseFloat(s);
@@ -288,12 +256,13 @@
         try {
             XMLStreamReader r = StAXUtils.createXMLStreamReader(
                     new ByteArrayInputStream(s.getBytes()));
-            StAXOMBuilder builder = new StAXOMBuilder(OMAbstractFactory.getOMFactory(),r);
+            StAXOMBuilder builder = new StAXOMBuilder(OMAbstractFactory.getOMFactory(), r);
             return builder.getDocumentElement();
         } catch (XMLStreamException e) {
             return null;
         }
     }
+
     public static YearMonth convertToGYearMonth(String s) {
         return new YearMonth(s);
     }
@@ -324,17 +293,17 @@
     }
 
     public static javax.activation.DataHandler convertToBase64Binary(String s)
-            throws Exception{
+            throws Exception {
         // reusing the byteArrayDataSource from the Axiom classes
         ByteArrayDataSource byteArrayDataSource = new ByteArrayDataSource(
                 Base64.decode(s)
         );
         return new DataHandler(byteArrayDataSource);
     }
-    
+
     public static javax.activation.DataHandler convertToDataHandler(String s)
-    		throws Exception{
-    	return convertToBase64Binary(s);
+            throws Exception {
+        return convertToBase64Binary(s);
     }
 
     /**
@@ -399,7 +368,6 @@
     }
 
 
-
     public static NormalizedString convertToNormalizedString(String s) {
         return new NormalizedString(s);
     }
@@ -449,9 +417,9 @@
     }
 
     public static Id convertToId(String s) {
-    	return convertToID(s);
+        return convertToID(s);
     }
-        
+
     public static Language convertToLanguage(String s) {
         return new Language(s);
     }
@@ -494,9 +462,9 @@
     }
 
     public static BigInteger convertToBigInteger(String s) {
-    	return convertToInteger(s);
+        return convertToInteger(s);
     }
-    
+
     public static byte convertToByte(String s) throws Exception {
         return Byte.parseByte(s);
     }
@@ -504,6 +472,7 @@
     /**
      * Code from Axis1 code base
      * Note - We only follow the convention in the latest schema spec
+     *
      * @param source
      * @return Returns Calendar.
      * @throws Exception
@@ -616,19 +585,19 @@
 
     /**
      * Code from Axis1 code base
+     *
      * @param source
      * @return Returns QName.
      */
     public static QName convertToQName(String source) {
         source = source.trim();
         int colon = source.lastIndexOf(":");
-        String namespace = colon < 0 ? "" : "" ;// todo Fix this. Need to take a namespace
with this
+        String namespace = colon < 0 ? "" : "";// todo Fix this. Need to take a namespace
with this
         //context.getNamespaceURI(source.substring(0, colon));
         String localPart = colon < 0 ? source : source.substring(colon + 1);
         return new QName(namespace, localPart);
     }
 
-
     /* ################################################################# */
 
     /* java Primitive types to Object conversion methods */
@@ -707,26 +676,33 @@
             for (int i = 0; i < listSize; i++) {
                 Array.setDouble(returnArray, i, Double.parseDouble(objectList.get(i).toString()));
             }
-        } else{
-            ConvertToArbitraryObjectArray( returnArray, baseArrayClass, objectList);
+        } else {
+            ConvertToArbitraryObjectArray(returnArray, baseArrayClass, objectList);
         }
         return returnArray;
     }
 
     /**
-     * 
      * @param returnArray
      * @param baseArrayClass
      * @param objectList
      */
-    private static void ConvertToArbitraryObjectArray(                                  
                  Object returnArray,
+    private static void ConvertToArbitraryObjectArray(Object returnArray,
                                                       Class baseArrayClass,
                                                       List objectList) {
         try {
             for (int i = 0; i < objectList.size(); i++) {
-                Array.set(returnArray, i, getObjectForClass(
-                        baseArrayClass,
-                        objectList.get(i).toString()));
+                Object o = objectList.get(i);
+                if (o == null) {
+                    Array.set(returnArray, i, getObjectForClass(
+                            baseArrayClass,
+                            null));
+                } else {
+                    Array.set(returnArray, i, getObjectForClass(
+                            baseArrayClass,
+                            o.toString()));
+                }
+
             }
             return;
         } catch (Exception e) {
@@ -735,7 +711,7 @@
         }
 
         try {
-            objectList.toArray((Object[])returnArray);
+            objectList.toArray((Object[]) returnArray);
         } catch (Exception e) {
             //we are over with alternatives - throw the
             //converison exception
@@ -746,14 +722,15 @@
     /**
      * We could have used the Arraya.asList() method
      * but that returns an *immutable* list !!!!!
+     *
      * @param array
      * @return
      */
-    public static List toList(Object[] array){
-        if (array==null){
+    public static List toList(Object[] array) {
+        if (array == null) {
             return new ArrayList();
-        }else{
-            ArrayList list =  new ArrayList();
+        } else {
+            ArrayList list = new ArrayList();
             for (int i = 0; i < array.length; i++) {
                 list.add(array[i]);
             }
@@ -763,9 +740,10 @@
 
     /**
      * Converts the given datahandler to a string
+     *
      * @return
      */
-    public static String getStringFromDatahandler(DataHandler dataHandler){
+    public static String getStringFromDatahandler(DataHandler dataHandler) {
         try {
             InputStream inStream;
             inStream = dataHandler.getDataSource().getInputStream();
@@ -779,11 +757,12 @@
     /**
      * A reflection based method to generate an instance of
      * a given class and populate it with a given value
+     *
      * @param clazz
      * @param value
      * @return
      */
-    public static Object getObjectForClass(Class clazz,String value){
+    public static Object getObjectForClass(Class clazz, String value) {
         //first see whether this class has a constructor that can
         //take the string as an argument.
         boolean continueFlag = false;
@@ -801,16 +780,16 @@
                     e);
         }
 
-        if (!continueFlag){
+        if (!continueFlag) {
             throw new ObjectConversionException(
                     ADBMessages.getMessage("converter.cannotConvert",
                             clazz.getName()));
         }
 
         try {
-            Method parseMethod =  clazz.getMethod("parse",new Class[]{String.class});
+            Method parseMethod = clazz.getMethod("parse", new Class[]{String.class});
             Object instance = clazz.newInstance();
-            return parseMethod.invoke(instance,new Object[]{value});
+            return parseMethod.invoke(instance, new Object[]{value});
         } catch (NoSuchMethodException e) {
             throw new ObjectConversionException(
                     ADBMessages.getMessage("converter.cannotConvert",
@@ -827,7 +806,7 @@
     /**
      * A simple exception that is thrown when the conversion fails
      */
-    public static class ObjectConversionException extends RuntimeException{
+    public static class ObjectConversionException extends RuntimeException {
         public ObjectConversionException() {
         }
 

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java?rev=439165&r1=439164&r2=439165&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
Thu Aug 31 21:13:43 2006
@@ -41,8 +41,6 @@
 import org.apache.axis2.rpc.client.RPCServiceClient;
 import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
 import org.apache.axis2.wsdl.WSDLConstants;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.FactoryConfigurationError;
@@ -62,7 +60,6 @@
 
 
     protected EndpointReference targetEPR;
-	private static final Log log = LogFactory.getLog(RPCCallTest.class);
     protected QName serviceName = new QName("EchoXMLService");
     protected QName operationName = new QName("http://org.apache.axis2/xsd", "concat");
     protected QName transportName = new QName("http://org.apache.axis2/xsd",

Modified: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java?rev=439165&r1=439164&r2=439165&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java
(original)
+++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java
Thu Aug 31 21:13:43 2006
@@ -358,6 +358,7 @@
         if (isArray) {
             elt1.setMaxOccurs(Long.MAX_VALUE);
             elt1.setMinOccurs(1);
+            elt1.setNillable(true);
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message