Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-6071

CXF's WSDL2Java tool can generate impl classes that jdk compiler will refuse to compile

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.1, 3.0.2
    • 3.0.3
    • Tooling
    • None
    • All

    • Unknown

    Description

      When using Apache CXF 3.0.1 and above the following WSDL (attached) will compile with the wsdl2java tool, however the code cannot be compiled as the implementation class cannot be compiled with any JDK.

      The issue is that the generated implementation class has a "." in the class name.

      eg:
      D:\programming\artix\apache-cxf-3.0.1-bin\bin\test>dir /b com\iona\schemas\idl\iacc_idl*Impl.java
      CORBAPortImpl.java
      IACC.ServerCORBAPortImpl.java

      Below is a patch that works around the issue, while still keeping the current functionality in place, only switching back to the old functionality (changed in: CXF-5456) when the port name contains non-valid characters as far as a JVM compiler is concerned.

      diff --git a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/ImplGenerator.java b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/ImplGenerator.java
      index 5fe090d..63dc84d 100644
      --- a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/ImplGenerator.java
      +++ b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/ImplGenerator.java
      @@ -21,6 +21,8 @@ package org.apache.cxf.tools.wsdlto.frontend.jaxws.generators;
      
       import java.util.HashMap;
       import java.util.Map;
      +import java.util.regex.Pattern;
      +import java.util.regex.Matcher;
      
       import javax.xml.namespace.QName;
      
      @@ -126,12 +128,17 @@ public class ImplGenerator extends AbstractJAXWSGenerator {
               }
               String name = nm.get(service + "/" + port);
               if (name == null) {
      -            name = port + "Impl";
      +            name = (isPortNameCompliant(port)) ? port : intf.getName() + "Impl";
                   name = mapClassName(intf.getPackageName(), name, penv);
                   nm.put(service + "/" + port, name);
               }
               return name;
           }
      +
      +    private boolean isPortNameCompliant(String port) {
      +        return Pattern.matches("[a-zA-Z]\\w*", port);
      +    }
      +
           private String mapClassName(String packageName, String name, ToolContext context) {
               ClassCollector collector = context.get(ClassCollector.class);
               int count = 0;
      

      Attachments

        1. iacc_servants.wsdl
          94 kB
          Keith Halligan

        Activity

          People

            dkulp Daniel Kulp
            khalligan Keith Halligan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: