cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r723024 - in /cxf/trunk: rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ systests/src/test/java/org/apache/cxf/systest/jaxws/
Date Wed, 03 Dec 2008 19:24:56 GMT
Author: dkulp
Date: Wed Dec  3 11:24:56 2008
New Revision: 723024

URL: http://svn.apache.org/viewvc?rev=723024&view=rev
Log:
[CXF-1930] Fix for anonymous wrappers when asm is found

Modified:
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ServerMisc.java

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java?rev=723024&r1=723023&r2=723024&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
Wed Dec  3 11:24:56 2008
@@ -161,14 +161,17 @@
                                         boolean isRequest) {
 
         QName wrapperElement = messageInfo.getName();
+        
+        boolean anonymous = factory.getAnonymousWrapperTypes();
 
         ClassWriter cw = createClassWriter();
-        String className = getPackageName(method) + ".jaxws_asm." 
+        String pkg = getPackageName(method) + ".jaxws_asm" + (anonymous ? "_an" : "");
+        String className =  pkg + "." 
             + StringUtils.capitalize(op.getName().getLocalPart());
         if (!isRequest) {
             className = className + "Response";
         }
-        String pname = getPackageName(method) + ".jaxws_asm.package-info";
+        String pname = pkg + ".package-info";
         Class<?> def = findClass(pname, method.getDeclaringClass());
         if (def == null) {
             generatePackageInfo(pname, wrapperElement.getNamespaceURI(),
@@ -195,8 +198,12 @@
         av0.visitEnd();
 
         av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlType;", true);
-        av0.visit("name", wrapperElement.getLocalPart());
-        av0.visit("namespace", wrapperElement.getNamespaceURI());
+        if (!anonymous) {
+            av0.visit("name", wrapperElement.getLocalPart());
+            av0.visit("namespace", wrapperElement.getNamespaceURI());
+        } else {
+            av0.visit("name", "");            
+        }
         av0.visitEnd();
 
         // add constructor

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java?rev=723024&r1=723023&r2=723024&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
Wed Dec  3 11:24:56 2008
@@ -19,12 +19,16 @@
 
 package org.apache.cxf.systest.jaxws;
 
+import java.io.InputStream;
 import java.lang.reflect.UndeclaredThrowableException;
+import java.net.HttpURLConnection;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import javax.xml.namespace.QName;
@@ -32,6 +36,10 @@
 import javax.xml.ws.Service;
 import javax.xml.ws.soap.SOAPBinding;
 import javax.xml.ws.soap.SOAPFaultException;
+import javax.xml.xpath.XPathConstants;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
 
 import org.apache.cxf.anonymous_complex_type.AnonymousComplexType;
 import org.apache.cxf.anonymous_complex_type.AnonymousComplexTypeService;
@@ -39,7 +47,10 @@
 import org.apache.cxf.anonymous_complex_type.RefSplitNameResponse;
 import org.apache.cxf.anonymous_complex_type.SplitName;
 import org.apache.cxf.anonymous_complex_type.SplitNameResponse.Names;
+import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.helpers.XPathUtils;
 import org.apache.cxf.jaxb_element_test.JaxbElementTest;
 import org.apache.cxf.jaxb_element_test.JaxbElementTest_Service;
 import org.apache.cxf.ordered_param_holder.ComplexStruct;
@@ -556,4 +567,44 @@
         assertEquals(2, port.operationInSub1(2));
         assertEquals(3, port.operationInSub2(3));
     }
+    
+    
+    
+    @Test
+    public void testAnonymousMinOccursConfig() throws Exception {
+        HttpURLConnection httpConnection = 
+            getHttpConnection(ServerMisc.DOCLIT_CODEFIRST_SETTINGS_URL + "?wsdl");    
+        httpConnection.connect();        
+        
+        assertEquals(200, httpConnection.getResponseCode());
+        assertEquals("OK", httpConnection.getResponseMessage());
+        InputStream in = httpConnection.getInputStream();
+        assertNotNull(in);
+        
+        Document doc = XMLUtils.parse(in);
+        assertNotNull(doc);
+        
+        
+        Map<String, String> ns = new HashMap<String, String>();
+        ns.put("soap", Soap11.SOAP_NAMESPACE);
+        ns.put("tns", "http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService");
+        ns.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
+        ns.put("xs", "http://www.w3.org/2001/XMLSchema");
+        
+        
+        XPathUtils xu = new XPathUtils(ns);
+        
+        //make sure the wrapper types are anonymous types
+        Node ct = (Node) xu.getValue("//wsdl:definitions/wsdl:types/xs:schema"
+                                     + "/xs:element[@name='getFooSetResponse']/xs:complexType/xs:sequence",
+                                     doc, XPathConstants.NODE);
+        assertNotNull(ct);
+        
+        //make sure the params are nillable, not minOccurs=0
+        ct = (Node) xu.getValue("//wsdl:definitions/wsdl:types/xs:schema"
+                                + "/xs:element[@name='multiInOut']/xs:complexType/xs:sequence"
+                                + "/xs:element[@nillable='true']",
+                                doc, XPathConstants.NODE);
+        assertNotNull(ct);
+    }
 }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ServerMisc.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ServerMisc.java?rev=723024&r1=723023&r2=723024&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ServerMisc.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ServerMisc.java Wed Dec
 3 11:24:56 2008
@@ -26,9 +26,11 @@
 import org.apache.cxf.jaxws.JAXWSMethodInvoker;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.ordered_param_holder.OrderedParamHolderImpl;
+import org.apache.cxf.service.factory.AbstractServiceConfiguration;
 import org.apache.cxf.service.invoker.Factory;
 import org.apache.cxf.service.invoker.PerRequestFactory;
 import org.apache.cxf.service.invoker.PooledFactory;
+import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 
 
@@ -41,6 +43,8 @@
         "http://localhost:9003/DocLitWrappedCodeFirstServiceBaseService/";
     public static final String DOCLITBARE_CODEFIRST_URL = 
         "http://localhost:9003/DocLitBareCodeFirstService/";
+    public static final String DOCLIT_CODEFIRST_SETTINGS_URL = 
+        "http://localhost:9003/DocLitWrappedCodeFirstServiceSettings/";
     
     protected void run() {
         
@@ -48,11 +52,28 @@
         factory = new PooledFactory(factory, 4);
         
         JAXWSMethodInvoker invoker = new JAXWSMethodInvoker(factory);
-        JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean();
+        JaxWsServerFactoryBean factoryBean;
+        
+        factoryBean = new JaxWsServerFactoryBean();
         factoryBean.setAddress(DOCLIT_CODEFIRST_URL);
         factoryBean.setServiceClass(DocLitWrappedCodeFirstServiceImpl.class);
         factoryBean.setInvoker(invoker);
         factoryBean.create();
+        
+        factoryBean = new JaxWsServerFactoryBean();
+        factoryBean.setAddress(DOCLIT_CODEFIRST_SETTINGS_URL);
+        factoryBean.setServiceClass(DocLitWrappedCodeFirstServiceImpl.class);
+        factoryBean.setInvoker(invoker);
+        factoryBean.getServiceFactory().setAnonymousWrapperTypes(true);
+        factoryBean.getServiceFactory().getServiceConfigurations().add(0, new AbstractServiceConfiguration()
{
+            public Boolean isWrapperPartNillable(MessagePartInfo mpi) {
+                return Boolean.TRUE;
+            }
+            public Long getWrapperPartMinOccurs(MessagePartInfo mpi) {
+                return Long.valueOf(1L);
+            }
+        });
+        factoryBean.create();
          
         //Object implementor4 = new DocLitWrappedCodeFirstServiceImpl();
         //Endpoint.publish(DOCLIT_CODEFIRST_URL, implementor4);



Mime
View raw message