cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1038378 - in /cxf/branches/2.3.x-fixes: ./ tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/valida...
Date Tue, 23 Nov 2010 23:20:43 GMT
Author: dkulp
Date: Tue Nov 23 23:20:42 2010
New Revision: 1038378

URL: http://svn.apache.org/viewvc?rev=1038378&view=rev
Log:
Merged revisions 1038374 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1038374 | dkulp | 2010-11-23 18:12:13 -0500 (Tue, 23 Nov 2010) | 2 lines
  
  [CXF-3105] Properly map the parameter names specified in the binding
  file by checking the message name  as well as the element name.
........

Added:
    cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf3105/
      - copied from r1038374, cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf3105/
    cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf3105/cxf3105.wsdl
      - copied unchanged from r1038374, cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf3105/cxf3105.wsdl
    cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf3105/ws-binding.xml
      - copied unchanged from r1038374, cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf3105/ws-binding.xml
Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java
    cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/validator/WrapperStyleNameCollisionValidator.java
    cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 23 23:20:42 2010
@@ -1 +1 @@
-/cxf/trunk:1038206
+/cxf/trunk:1038206,1038374

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java?rev=1038378&r1=1038377&r2=1038378&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java
(original)
+++ cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java
Tue Nov 23 23:20:42 2010
@@ -239,17 +239,11 @@ public class ParameterProcessor extends 
             && countOutOfBandHeader(inputMessage) == 0) {
             return;
         }
-        JAXWSBinding mBinding = inputMessage.getOperation().getExtensor(JAXWSBinding.class);
         for (QName item : wrappedElements) {
             JavaParameter jp = getParameterFromQName(part.getElementQName(),
                                   item, JavaType.Style.IN, part);
-            if (mBinding != null && mBinding.getJaxwsParas() != null) {
-                for (JAXWSParameter jwsp : mBinding.getJaxwsParas()) {
-                    if (item.equals(jwsp.getElementName())) {
-                        jp.setName(jwsp.getName());
-                    }
-                }
-            }
+            
+            checkPartName(inputMessage, item, jp);
             
             if (StringUtils.isEmpty(part.getConcreteName().getNamespaceURI())) { 
                 jp.setTargetNamespace("");
@@ -479,7 +473,9 @@ public class ParameterProcessor extends 
                         }
                         if (!jpIn.getClassName().equals(jp.getClassName())) {
                             jp.setStyle(JavaType.Style.OUT);
+                            checkPartName(outputMessage, outElement, jp);
                         }
+
                         addParameter(method, jp);
                         sameWrapperChild = true;
                         break;
@@ -492,15 +488,7 @@ public class ParameterProcessor extends 
                 if (!qualified && !isRefElement(outputPart, outElement)) {
                     jp.setTargetNamespace("");
                 }
-                
-                JAXWSBinding mBinding = outputMessage.getOperation().getExtensor(JAXWSBinding.class);
-                if (mBinding != null && mBinding.getJaxwsParas() != null) {
-                    for (JAXWSParameter jwsp : mBinding.getJaxwsParas()) {
-                        if (outElement.equals(jwsp.getElementName())) {
-                            jp.setName(jwsp.getName());
-                        }
-                    }
-                }
+                checkPartName(outputMessage, outElement, jp);
     
                 addParameter(method, jp);
             }
@@ -509,7 +497,17 @@ public class ParameterProcessor extends 
             addVoidReturn(method);
         }
     }
-
+    private void checkPartName(MessageInfo message, QName element, JavaParameter jp) {
+        JAXWSBinding mBinding = message.getOperation().getExtensor(JAXWSBinding.class);
+        if (mBinding != null && mBinding.getJaxwsParas() != null) {
+            for (JAXWSParameter jwsp : mBinding.getJaxwsParas()) {
+                if (element.getLocalPart().equals(jwsp.getElementName().getLocalPart())
+                    && jwsp.getMessageName().equals(message.getName().getLocalPart()))
{
+                    jp.setName(jwsp.getName());
+                }
+            }
+        }        
+    }
     private void addVoidReturn(JavaMethod method) {
         JavaReturn returnType = new JavaReturn("return", "void", null);
         method.setReturn(returnType);

Modified: cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/validator/WrapperStyleNameCollisionValidator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/validator/WrapperStyleNameCollisionValidator.java?rev=1038378&r1=1038377&r2=1038378&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/validator/WrapperStyleNameCollisionValidator.java
(original)
+++ cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/validator/WrapperStyleNameCollisionValidator.java
Tue Nov 23 23:20:42 2010
@@ -28,6 +28,7 @@ import javax.xml.namespace.QName;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.service.model.MessageInfo;
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.service.model.ServiceInfo;
@@ -35,6 +36,7 @@ import org.apache.cxf.tools.common.ToolC
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.validator.ServiceValidator;
 import org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding;
+import org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSParameter;
 import org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.ProcessorUtil;
 import org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.WrapperElement;
 
@@ -105,17 +107,21 @@ public class WrapperStyleNameCollisionVa
             output = operation.getOutput().getMessageParts().iterator().next();
         }
         if (!c) {
-            Map<QName, QName> names = new HashMap<QName, QName>();
+            Map<String, QName> names = new HashMap<String, QName>();
             if (input != null) {
                 for (WrapperElement element : ProcessorUtil.getWrappedElement(context, 
                                                                               input.getElementQName()))
{
-                    if (names.containsKey(element.getElementName())
-                        &&  (names.get(element.getElementName()) == element.getSchemaTypeName()
-                            || names.get(element.getElementName()).equals(element.getSchemaTypeName())))
{
-                        handleErrors(names.get(element.getElementName()), element);
+                    
+                    String mappedName = mapElementName(operation,
+                                                      operation.getUnwrappedOperation().getInput(),
+                                                      element);
+                    if (names.containsKey(mappedName)
+                        &&  (names.get(mappedName) == element.getSchemaTypeName()
+                            || names.get(mappedName).equals(element.getSchemaTypeName())))
{
+                        handleErrors(names.get(mappedName), element);
                         return false;
                     } else {
-                        names.put(element.getElementName(), element.getSchemaTypeName());
+                        names.put(mappedName, element.getSchemaTypeName());
                     }
                 }
             }
@@ -124,13 +130,16 @@ public class WrapperStyleNameCollisionVa
                 List<WrapperElement> els = ProcessorUtil.getWrappedElement(context,
output.getElementQName());
                 if (els.size() > 1) {
                     for (WrapperElement element : els) {
-                        if (names.containsKey(element.getElementName())
-                            &&  !(names.get(element.getElementName()) == element.getSchemaTypeName()
-                                || names.get(element.getElementName()).equals(element.getSchemaTypeName())))
{
-                            handleErrors(names.get(element.getElementName()), element);
+                        String mappedName = mapElementName(operation,
+                                                           operation.getUnwrappedOperation().getOutput(),
+                                                           element);
+                        if (names.containsKey(mappedName)
+                            &&  !(names.get(mappedName) == element.getSchemaTypeName()
+                                || names.get(mappedName).equals(element.getSchemaTypeName())))
{
+                            handleErrors(names.get(mappedName), element);
                             return false;
                         } else {
-                            names.put(element.getElementName(), element.getSchemaTypeName());
+                            names.put(mappedName, element.getSchemaTypeName());
                         }
                     }
                 }
@@ -139,6 +148,20 @@ public class WrapperStyleNameCollisionVa
         return true;
     }
 
+    private String mapElementName(OperationInfo op, MessageInfo mi, WrapperElement element)
{
+        MessagePartInfo mpi = mi.getMessagePart(element.getElementName());
+        JAXWSBinding bind = op.getExtensor(JAXWSBinding.class);
+        if (bind != null && bind.getJaxwsParas() != null) {
+            for (JAXWSParameter par : bind.getJaxwsParas()) {
+                if (mi.getName().getLocalPart().equals(par.getMessageName())
+                    && mpi.getName().getLocalPart().equals(par.getElementName().getLocalPart()))
{
+                    return par.getName();
+                }
+            }
+        }
+        return mpi.getElementQName().getLocalPart();
+    }
+
     private void handleErrors(QName e1, WrapperElement e2) {
         Message msg = new Message("WRAPPER_STYLE_NAME_COLLISION", LOG, 
                                   e2.getElementName(), e1, e2.getSchemaTypeName());

Modified: cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?rev=1038378&r1=1038377&r2=1038378&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
(original)
+++ cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
Tue Nov 23 23:20:42 2010
@@ -1136,4 +1136,21 @@ public class CodeGenBugTest extends Abst
                             "org/apache/cxf/w2j/hello_world_soap_http/TestServiceName1.java").exists());
     }
 
+    
+    @Test
+    public void testCXF3105() throws Exception {
+        String[] args = new String[] {"-d", output.getCanonicalPath(),
+            "-impl", "-server", "-client", 
+            "-b", getLocation("/wsdl2java_wsdl/cxf3105/ws-binding.xml"),
+            getLocation("/wsdl2java_wsdl/cxf3105/cxf3105.wsdl")};
+        WSDLToJava.main(args);
+
+        assertNotNull(output);
+        File f = new File(output, "org/apache/cxf/testcase/cxf3105/Login.java");
+        assertTrue(f.exists());
+        String contents = IOUtils.readStringFromStream(new FileInputStream(f));
+        assertTrue(contents.contains("Loginrequest loginRequest"));
+        assertTrue(contents.contains("<Loginresponse> loginResponse"));
+    }
+
 }



Mime
View raw message