Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-5919

WSDL2Java not working properly when using jaxbri and WSDL with faults

    XMLWordPrintableJSON

Details

    • Important

    Description

      We are currently unable to use newer version of Axis2 (1.7.7) because the Java classes generated by axis2-codegen and axis2-jaxbri have missing parameter errors.

      When you generate Java classes from WSDL that contains faults you get errors in the newly generated classes: "The method toOM(TestFaultStruct, boolean, QName) in the type <class> is not applicable for the arguments (TestFaultStruct, boolean)". The reason you get that is because the QName parameter is missing when calling toOM in faults.

      The error happens because:

      • all toOM methods code is generated using JaxbRIDatabindingTemplate.xsl (axis2-jaxbri) and they all have QName parameter defined
      • all custom faults code is generated using MessageReceiverTemplate.xsl (axis2-codegen) and if you look at the xsl code you can see that QName parameter is not there:
                <xsl:for-each select="fault-list/fault">
                    <xsl:if test="position()=1">}</xsl:if> catch (<xsl:value-of select="@name"/> e) {
        
                    msgContext.setProperty(org.apache.axis2.Constants.FAULT_NAME,"<xsl:value-of select="@localname"/>");
                    org.apache.axis2.AxisFault f = createAxisFault(e);
                    if (e.getFaultMessage() != null){
                        f.setDetail(toOM(e.getFaultMessage(),false));
                    }
                    throw f;
                    }
                </xsl:for-each>
        

       

      How to reproduce:

      • Download and extract axis2-1.7.7
      • Execute WSDL2Java:
        java -Dfile.encoding=UTF-8 -Djavax.xml.accessExternalSchema=all -classpath "c:\DevStudio\axis2-1.7.7\lib\*;" org.apache.axis2.wsdl.WSDL2Java -uri "c:\DevStudio\axis2-1.7.7\samples\faulthandling\bank.wsdl" -o "%CD%\GEN" -d jaxbri -ss -g -or -p com.company.generated
        
      • Compile code (eclipse/ant ...)
        Buildfile: C:\TEMP\Test\GEN\build.xml
        
        init:
            [mkdir] Created dir: C:\TEMP\Test\GEN\build
            [mkdir] Created dir: C:\TEMP\Test\GEN\build\classes
            [mkdir] Created dir: C:\TEMP\Test\GEN\build\lib
        
        pre.compile.test:
             [echo] JAX-B RI Availability = true
             [echo] Stax Availability= true
             [echo] Axis2 Availability= true
        
        compile.src:
            [javac] C:\TEMP\Test\GEN\build.xml:47: warning: 'includeantruntime' was not set, defaulting to build.sysclasspat
        h=last; set to false for repeatable builds
            [javac] Compiling 12 source files to C:\TEMP\Test\GEN\build\classes
            [javac] C:\TEMP\Test\GEN\src\com\company\generated\BankServiceMessageReceiverInOut.java:89: error: no suitable m
        ethod found for toOM(AccountNotExistFault,boolean)
            [javac]                 f.setDetail(toOM(e.getFaultMessage(), false));
            [javac]                             ^
            [javac]     method BankServiceMessageReceiverInOut.toOM(InsufficientFundFault,boolean,QName) is not applicable
            [javac]       (actual and formal argument lists differ in length)
            [javac]     method BankServiceMessageReceiverInOut.toOM(AccountNotExistFault,boolean,QName) is not applicable
            [javac]       (actual and formal argument lists differ in length)
            [javac]     method BankServiceMessageReceiverInOut.toOM(WithdrawResponse,boolean,QName) is not applicable
            [javac]       (actual and formal argument lists differ in length)
            [javac]     method BankServiceMessageReceiverInOut.toOM(Withdraw,boolean,QName) is not applicable
            [javac]       (actual and formal argument lists differ in length)
            [javac] C:\TEMP\Test\GEN\src\com\company\generated\BankServiceMessageReceiverInOut.java:100: error: no suitable
        method found for toOM(InsufficientFundFault,boolean)
            [javac]                 f.setDetail(toOM(e.getFaultMessage(), false));
            [javac]                             ^
            [javac]     method BankServiceMessageReceiverInOut.toOM(InsufficientFundFault,boolean,QName) is not applicable
            [javac]       (actual and formal argument lists differ in length)
            [javac]     method BankServiceMessageReceiverInOut.toOM(AccountNotExistFault,boolean,QName) is not applicable
            [javac]       (actual and formal argument lists differ in length)
            [javac]     method BankServiceMessageReceiverInOut.toOM(WithdrawResponse,boolean,QName) is not applicable
            [javac]       (actual and formal argument lists differ in length)
            [javac]     method BankServiceMessageReceiverInOut.toOM(Withdraw,boolean,QName) is not applicable
            [javac]       (actual and formal argument lists differ in length)
            [javac] Note: Some input files use unchecked or unsafe operations.
            [javac] Note: Recompile with -Xlint:unchecked for details.
            [javac] 2 errors
        
        BUILD FAILED
        C:\TEMP\Test\GEN\build.xml:47: Compile failed; see the compiler error output for details.
        
        Total time: 2 seconds
        

      Attachments

        Issue Links

          Activity

            People

              veithen Andreas Veithen
              fineos.obradovice Edi Obradovic
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: