cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1002841 - in /cxf/trunk: rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/
Date Wed, 29 Sep 2010 20:46:34 GMT
Author: dkulp
Date: Wed Sep 29 20:46:34 2010
New Revision: 1002841

URL: http://svn.apache.org/viewvc?rev=1002841&view=rev
Log:
Fix an issue of using an @XmlList with a doc/lit/bare service

Modified:
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/DocLitBareCodeFirstService.java
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/DocLitBareCodeFirstServiceImpl.java

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java?rev=1002841&r1=1002840&r2=1002841&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
(original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
Wed Sep 29 20:46:34 2010
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlList;
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import javax.xml.namespace.QName;
@@ -54,6 +55,9 @@ import org.apache.ws.commons.schema.XmlS
 import org.apache.ws.commons.schema.XmlSchemaForm;
 import org.apache.ws.commons.schema.XmlSchemaObject;
 import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
+import org.apache.ws.commons.schema.XmlSchemaSimpleTypeList;
+import org.apache.ws.commons.schema.XmlSchemaType;
 import org.apache.ws.commons.schema.utils.NamespaceMap;
 
 /**
@@ -139,8 +143,20 @@ class JAXBSchemaInitializer extends Serv
         }
 
         boolean isFromWrapper = part.getMessageInfo().getOperation().isUnwrapped();
-        if (isFromWrapper && clazz.isArray() && !Byte.TYPE.equals(clazz.getComponentType()))
{
-            clazz = clazz.getComponentType();
+        boolean isList = false;
+        if (clazz.isArray()) {
+            if (isFromWrapper && !Byte.TYPE.equals(clazz.getComponentType())) {
+                clazz = clazz.getComponentType();
+            } else if (!isFromWrapper) {
+                Annotation[] anns = (Annotation[])part.getProperty("parameter.annotations");
+                for (Annotation a : anns) {
+                    if (a instanceof XmlList) {
+                        part.setProperty("honor.jaxb.annotations", Boolean.TRUE);
+                        clazz = clazz.getComponentType();
+                        isList = true;
+                    }
+                }
+            }
         }
 
         JAXBBeanInfo beanInfo = getBeanInfo(clazz);
@@ -203,8 +219,21 @@ class JAXBSchemaInitializer extends Serv
         } else  {
             QName typeName = getTypeName(beanInfo);
             if (typeName != null) {
-                part.setTypeQName(typeName);
-                part.setXmlSchema(schemas.getTypeByQName(typeName));
+                XmlSchemaType type = schemas.getTypeByQName(typeName);
+                if  (isList && type instanceof XmlSchemaSimpleType) {
+                    XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(null);
+                    XmlSchemaSimpleTypeList list = new XmlSchemaSimpleTypeList();
+                    XmlSchemaSimpleType stype = (XmlSchemaSimpleType)type;
+                    list.setItemTypeName(stype.getQName());
+                    simpleType.setContent(list);
+                    part.setXmlSchema(simpleType);
+                    if (part.getConcreteName() == null) {
+                        part.setConcreteName(new QName(null, part.getName().getLocalPart()));
+                    }
+                } else {
+                    part.setTypeQName(typeName);
+                    part.setXmlSchema(type);
+                }
             }
         }
     }

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=1002841&r1=1002840&r2=1002841&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Wed Sep 29 20:46:34 2010
@@ -1176,16 +1176,22 @@ public class ReflectionServiceFactoryBea
                 mpi.setConcreteName(qname);
                 continue;
             } else {
-                if (null == mpi.getTypeQName()) {
+                if (null == mpi.getTypeQName() && mpi.getXmlSchema() == null) {
                     throw new ServiceConstructionException(new Message("UNMAPPABLE_PORT_TYPE",
LOG,
                                                                        method.getDeclaringClass().getName(),
                                                                        method.getName(),
                                                                        mpi.getName()));
                 }
-                el.setSchemaTypeName(mpi.getTypeQName());
+                if (mpi.getTypeQName() != null) {
+                    el.setSchemaTypeName(mpi.getTypeQName());
+                } else {
+                    el.setSchemaType((XmlSchemaType)mpi.getXmlSchema());
+                }
                 mpi.setXmlSchema(el);
                 mpi.setConcreteName(qname);
-                addImport(schema, mpi.getTypeQName().getNamespaceURI());
+                if (mpi.getTypeQName() != null) {
+                    addImport(schema, mpi.getTypeQName().getNamespaceURI());
+                }
             }
 
             mpi.setElement(true);

Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java?rev=1002841&r1=1002840&r2=1002841&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
(original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
Wed Sep 29 20:46:34 2010
@@ -22,6 +22,7 @@ package org.apache.cxf.systest.jaxws;
 import java.io.InputStream;
 import java.lang.reflect.Field;
 import java.lang.reflect.UndeclaredThrowableException;
+import java.math.BigInteger;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.util.ArrayList;
@@ -184,12 +185,20 @@ public class ClientServerMiscTest extend
                                   DocLitBareCodeFirstService.class);
         DocLitBareCodeFirstService.GreetMeRequest req = 
             new DocLitBareCodeFirstService.GreetMeRequest();
-        req.setName("Foo");
-        DocLitBareCodeFirstService.GreetMeResponse resp =
-            port.greetMe(req);
+        DocLitBareCodeFirstService.GreetMeResponse resp;
+        BigInteger i[];
         
+        req.setName("Foo");
+        resp = port.greetMe(req);
         assertEquals(req.getName(), resp.getName());
         
+        i = port.sayTest(new DocLitBareCodeFirstService.SayTestRequest("Dan"));
+        assertEquals(4, i.length);
+        assertEquals(0, i[0].intValue());
+        assertEquals(1, i[1].intValue());
+        assertEquals(2, i[2].intValue());
+        assertEquals(3, i[3].intValue());
+        
         //try with wsdl
         service = Service.create(new URL(ServerMisc.DOCLITBARE_CODEFIRST_URL + "?wsdl"),
                                          servName);

Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/DocLitBareCodeFirstService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/DocLitBareCodeFirstService.java?rev=1002841&r1=1002840&r2=1002841&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/DocLitBareCodeFirstService.java
(original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/DocLitBareCodeFirstService.java
Wed Sep 29 20:46:34 2010
@@ -26,9 +26,11 @@ import javax.jws.soap.SOAPBinding;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlList;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
+
 @WebService(name = "DocLitBareCodeFirstService",
             targetNamespace = "http://cxf.apache.org/systest/jaxws/DocLitBareCodeFirstService")
 @SOAPBinding(style = SOAPBinding.Style.DOCUMENT,
@@ -43,6 +45,37 @@ public interface DocLitBareCodeFirstServ
                   GreetMeRequest gmr); 
     
     
+    @XmlList
+    @WebResult(name = "Items", targetNamespace = "http://namespace/result", partName = "parameter")
+    @WebMethod
+    java.math.BigInteger[] sayTest(
+        @WebParam(partName = "parameter", name = "SayTestRequest", targetNamespace = "http://www.tum.de/test")
+        SayTestRequest parameter
+    );
+    
+    
+    @XmlAccessorType(XmlAccessType.FIELD) 
+    @XmlType(name = "SayTestRequest", 
+             namespace = "http://cxf.apache.org/test/request/bare", 
+             propOrder = { "name" }) 
+    @XmlRootElement(namespace = "http://cxf.apache.org/test/request/bare",
+                    name = "SayTestObject") 
+    static class SayTestRequest  {
+        String name;
+        
+        public SayTestRequest() {
+        }
+        public SayTestRequest(String n) {
+            name = n;
+        }
+        
+        public void setName(String n) {
+            name = n;
+        }
+        public String getName() {
+            return name;
+        }
+    }
     @XmlAccessorType(XmlAccessType.FIELD) 
     @XmlType(name = "GreetMeRequest", 
              namespace = "http://cxf.apache.org/test/request/bare", 

Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/DocLitBareCodeFirstServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/DocLitBareCodeFirstServiceImpl.java?rev=1002841&r1=1002840&r2=1002841&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/DocLitBareCodeFirstServiceImpl.java
(original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/DocLitBareCodeFirstServiceImpl.java
Wed Sep 29 20:46:34 2010
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.systest.jaxws;
 
+import java.math.BigInteger;
+
 import javax.jws.WebService;
 import javax.xml.namespace.QName;
 import javax.xml.soap.SOAPException;
@@ -54,4 +56,13 @@ public class DocLitBareCodeFirstServiceI
         return resp;
     }
 
+    public BigInteger[] sayTest(SayTestRequest parameter) {
+        return new BigInteger[] {
+            BigInteger.valueOf(0),
+            BigInteger.valueOf(1),
+            BigInteger.valueOf(2),
+            BigInteger.valueOf(3),
+        };
+    }
+
 }



Mime
View raw message