cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r986022 - in /cxf/trunk: rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2941...
Date Mon, 16 Aug 2010 16:30:08 GMT
Author: ema
Date: Mon Aug 16 16:30:08 2010
New Revision: 986022

URL: http://svn.apache.org/viewvc?rev=986022&view=rev
Log:
[CXF-2941]:Get the namespace value from reference element in @XmlElement of response wrapper
bean

Added:
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2941/
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2941/WebResultService.java
Modified:
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java?rev=986022&r1=986021&r2=986022&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
Mon Aug 16 16:30:08 2010
@@ -433,11 +433,7 @@ public class JaxWsServiceConfiguration e
             String tns = null;
             String local = null;
             if (webResult != null) {
-                //if it's a "wrapped" thing, the WebResult namespace is irrelevant
-                //as the generated element has to be in the namespace of the wrapper type
-                if (webResult.header() || !op.isUnwrapped()) {
-                    tns = webResult.targetNamespace();
-                }
+                tns = webResult.targetNamespace();
                 local = webResult.name();
             }
             if (tns == null || tns.length() == 0) {

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java?rev=986022&r1=986021&r2=986022&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java
(original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java
Mon Aug 16 16:30:08 2010
@@ -27,6 +27,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import javax.jws.WebParam;
+import javax.jws.WebResult;
 import javax.xml.ws.Holder;
 
 import org.apache.cxf.common.util.CollectionUtils;
@@ -75,9 +76,17 @@ public final class ResponseWrapper exten
             return fields;
         }
         MessagePartInfo part = message.getMessageParts().get(0);
-
+        
         field.setName(part.getName().getLocalPart());
-
+        field.setTargetNamespace(part.getName().getNamespaceURI());
+               
+        if (method.getAnnotation(WebResult.class) == null 
+            && method.getAnnotation(javax.xml.ws.ResponseWrapper.class) == null
+            || method.getAnnotation(WebResult.class) != null 
+            && method.getAnnotation(WebResult.class).targetNamespace().equals(""))
{
+            field.setTargetNamespace("");   
+        }
+        
         boolean hasReturnType = false;
 
         if (!returnType.isAssignableFrom(void.class)) {
@@ -86,8 +95,6 @@ public final class ResponseWrapper exten
             List<Annotation> jaxbAnns = WrapperUtil.getJaxbAnnotations(method);
             field.setType(type);
             field.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[jaxbAnns.size()]));
-            field.setTargetNamespace("");
-
         }
         fields.add(field);
 

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2941/WebResultService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2941/WebResultService.java?rev=986022&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2941/WebResultService.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2941/WebResultService.java
Mon Aug 16 16:30:08 2010
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.tools.fortest.cxf2941;
+
+import javax.jws.WebMethod;
+import javax.jws.WebResult;
+
+public class WebResultService {
+    @WebMethod(operationName = "helloString", action = "urn:HelloString")
+    @WebResult(name = "name", partName = "name", targetNamespace = "hello/name")
+    public String hello(int age) {
+        return "Hello " + age + " to Web Service";
+    }
+}

Modified: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java?rev=986022&r1=986021&r2=986022&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
(original)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
Mon Aug 16 16:30:08 2010
@@ -79,6 +79,24 @@ public class JavaToWSTest extends ToolTe
         checkStdErr();
         assertTrue("Failed to generate WSDL file", wsdlFile.exists());
     }
+
+    @Test
+    public void testCXF2941() throws Exception {
+        String[] args = new String[] {
+            "-wsdl", "-wrapperbean", 
+            "-s", output.getPath(), 
+            "-o", output.getPath() + "/cxf2941.wsdl", 
+            "org.apache.cxf.tools.fortest.cxf2941.WebResultService"
+        };
+        JavaToWS.main(args);
+        File wrapper = outputFile("org/apache/cxf/tools/fortest/cxf2941/jaxws/HelloResponse.java");
+        String str = FileUtils.getStringFromFile(wrapper);
+        assertTrue("namespace value in annoataion @XmlElement is not correct"
+                   , str.indexOf("hello/name") > -1);
+        assertTrue("name value in annoataion @XmlElement is not correct"
+                   , str.indexOf("\"name\"") > -1);
+    }
+    
     
     @Test
     public void testCXF2934() throws Exception {



Mime
View raw message