cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1127324 - in /cxf/trunk: api/src/main/java/org/apache/cxf/databinding/ rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/ rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/ systests/databinding/src/test/java/o...
Date Tue, 24 May 2011 22:40:58 GMT
Author: dkulp
Date: Tue May 24 22:40:58 2011
New Revision: 1127324

URL: http://svn.apache.org/viewvc?rev=1127324&view=rev
Log:
[CXF-3541] Fix issues with XMLBeans with arrays in the wrappers

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractWrapperHelper.java
    cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java
    cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java
    cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
    cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/ClientServerXmlBeansTest.java
    cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/GreeterImpl.java
    cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/xmlbeans/hello_world.wsdl

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractWrapperHelper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractWrapperHelper.java?rev=1127324&r1=1127323&r2=1127324&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractWrapperHelper.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractWrapperHelper.java Tue
May 24 22:40:58 2011
@@ -125,6 +125,9 @@ public abstract class AbstractWrapperHel
             
             return ret;
         } catch (Exception ex) {
+            if (ex.getCause() == null) {
+                throw new Fault(ex);
+            }
             throw new Fault(ex.getCause());
         }
     }

Modified: cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java?rev=1127324&r1=1127323&r2=1127324&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java
(original)
+++ cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java
Tue May 24 22:40:58 2011
@@ -145,7 +145,13 @@ public class XmlBeansDataBinding extends
             try {
                 getMethod = valueClass.getMethod(getAccessor, AbstractWrapperHelper.NO_CLASSES);
             } catch (NoSuchMethodException ex) {
-                //ignore for now
+                try {
+                    getMethod = valueClass.getMethod(getAccessor + "Array", AbstractWrapperHelper.NO_CLASSES);
+                    getAccessor += "Array";
+                    setAccessor += "Array";
+                } catch (NoSuchMethodException ex2) {
+                    //ignore for now
+                }
             }
                         
             for (Method method : allMethods) {

Modified: cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java?rev=1127324&r1=1127323&r2=1127324&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java
(original)
+++ cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java
Tue May 24 22:40:58 2011
@@ -77,13 +77,26 @@ public class XmlBeansWrapperHelper exten
 
     @Override
     protected Object getWrapperObject(Object object) throws Exception {                 
          
-        Class<?> valueClass = getXMLBeansValueType(wrapperType);
-        // we need get the real Object first
-        Method method = wrapperType.getMethod("get" + valueClass.getSimpleName(), NO_CLASSES);
+        Method m = getXMLBeansValueMethod(wrapperType);
+        Method method = null;
+        if (m == null) {
+            Class<?> valueClass = getXMLBeansValueType(wrapperType);
+            // we need get the real Object first
+            method = wrapperType.getMethod("get" + valueClass.getSimpleName(), NO_CLASSES);
+        } else {
+            method = wrapperType.getMethod("get" + m.getName().substring(6), NO_CLASSES);
+        }
         return method.invoke(object, NO_PARAMS);
-        
     }
-    
+    public static Method getXMLBeansValueMethod(Class<?> wrapperType)  {
+        for (Method method : wrapperType.getMethods()) {
+            if (method.getName().startsWith("addNew")) {                
+                return method;
+            }
+        }
+        return null;
+    }
+
     public static Class<?> getXMLBeansValueType(Class<?> wrapperType)  {
         Class<?> result = wrapperType;
         for (Method method : wrapperType.getMethods()) {

Modified: cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java?rev=1127324&r1=1127323&r2=1127324&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
(original)
+++ cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
Tue May 24 22:40:58 2011
@@ -51,6 +51,7 @@ import org.apache.cxf.tools.common.model
 import org.apache.cxf.tools.util.ClassCollector;
 import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
 import org.apache.xmlbeans.SchemaGlobalElement;
+import org.apache.xmlbeans.SchemaProperty;
 import org.apache.xmlbeans.SchemaType;
 import org.apache.xmlbeans.SchemaTypeLoader;
 import org.apache.xmlbeans.SchemaTypeSystem;
@@ -168,8 +169,13 @@ public class XMLBeansToolingDataBinding 
         }
 
         SchemaType st = elem.getType();
-        SchemaType partType = st.getElementProperty(item).getType();        
-        return XMLBeansSchemaTypeUtils.getNaturalJavaClassName(partType);        
+        SchemaProperty prop = st.getElementProperty(item);
+        SchemaType partType = prop.getType();
+        String s = XMLBeansSchemaTypeUtils.getNaturalJavaClassName(partType);
+        if (prop.extendsJavaArray()) {
+            s += "[]";
+        }
+        return s;
     }
 
     public void generate(ToolContext context) throws ToolException {

Modified: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/ClientServerXmlBeansTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/ClientServerXmlBeansTest.java?rev=1127324&r1=1127323&r2=1127324&view=diff
==============================================================================
--- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/ClientServerXmlBeansTest.java
(original)
+++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/ClientServerXmlBeansTest.java
Tue May 24 22:40:58 2011
@@ -137,6 +137,10 @@ public class ClientServerXmlBeansTest ex
         
         resp = port.greetMe("Willem");
         assertEquals("We should get the right response", "Hello Willem", resp);
+        
+        String aresp[] = port.sayHiArray(new String[] {"Dan"});
+        assertEquals("Hello", aresp[0]);
+        assertEquals("Dan", aresp[1]);
 
         try {
             port.greetMe("fault");

Modified: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/GreeterImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/GreeterImpl.java?rev=1127324&r1=1127323&r2=1127324&view=diff
==============================================================================
--- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/GreeterImpl.java
(original)
+++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/GreeterImpl.java
Tue May 24 22:40:58 2011
@@ -76,5 +76,10 @@ public class GreeterImpl implements Gree
         throw new PingMeFault("PingMeFault raised by server", faultDocument);
     }
 
-    
+    public String[] sayHiArray(String requests[]) {
+        String ret[] = new String[requests.length + 1];
+        ret[0] = "Hello";
+        System.arraycopy(requests, 0, ret, 1, requests.length);
+        return ret;
+    }
 }

Modified: cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/xmlbeans/hello_world.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/xmlbeans/hello_world.wsdl?rev=1127324&r1=1127323&r2=1127324&view=diff
==============================================================================
--- cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/xmlbeans/hello_world.wsdl
(original)
+++ cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/xmlbeans/hello_world.wsdl
Tue May 24 22:40:58 2011
@@ -45,6 +45,22 @@
                     </sequence>
                 </complexType>
             </element>
+            
+            <element name="sayHiArray">
+                <complexType>
+                    <sequence>
+                        <element name="requests" minOccurs="0" maxOccurs="unbounded" type="string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="sayHiArrayResponse">
+                <complexType>
+                    <sequence>
+                        <element name="responses" minOccurs="0" maxOccurs="unbounded"
type="string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            
             <element name="greetMe">
                 <complexType>
                     <sequence>
@@ -89,6 +105,12 @@
     <wsdl:message name="sayHiResponse">
         <wsdl:part element="x1:sayHiResponse" name="out"/>
     </wsdl:message>
+    <wsdl:message name="sayHiArrayRequest">
+        <wsdl:part element="x1:sayHiArray" name="in"/>
+    </wsdl:message>
+    <wsdl:message name="sayHiArrayResponse">
+        <wsdl:part element="x1:sayHiArrayResponse" name="out"/>
+    </wsdl:message>
     <wsdl:message name="greetMeRequest">
         <wsdl:part element="x1:greetMe" name="in"/>
     </wsdl:message>
@@ -117,6 +139,10 @@
             <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
             <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
         </wsdl:operation>
+        <wsdl:operation name="sayHiArray">
+            <wsdl:input message="tns:sayHiArrayRequest" name="sayHiArrayRequest"/>
+            <wsdl:output message="tns:sayHiArrayResponse" name="sayHiArrayResponse"/>
+        </wsdl:operation>
         
 
         <wsdl:operation name="greetMe">
@@ -149,6 +175,16 @@
                 <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
+
+        <wsdl:operation name="sayHiArray">
+            <soap:operation soapAction="" style="document"/>
+            <wsdl:input name="sayHiArrayRequest">
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output name="sayHiArrayResponse">
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
         
 
         <wsdl:operation name="greetMe">



Mime
View raw message