Axis-C++
  1. Axis-C++
  2. AXISCPP-966

WSDL2WS generate wrong code: redundant value reference * in Wrapper

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.6 Beta
    • Fix Version/s: current (nightly)
    • Component/s: WSDL processing - RPC
    • Labels:
      None
    • Environment:

      Description

      [Error Statement]:
      I have used AxisCPP1.6Beta version to generate SampleTestSoapWrapper.cpp as the below:
      Function: int SampleTestSoapWrapper::GetOperation(void* pMsg)
      xsd_string v0 = *(pIWSDZ->getElementAsString("ListType", 0));

      The generated code has bug: xsd_string is already indeed a "char ", so should not reference it's content by "".

      The correct code I expected is:
      xsd_string v0 = pIWSDZ->getElementAsString("ListType", 0);

      [solution]:
      I have investigated the source code of AxisCPP/WSDL2Ws tool, and found that if I modify the following code at about line 217~234 in writeMethodInWrapper method that belongs to WrapWriter (wsdl2ws/cpp/iteral) class, the above bug can be resolved.

      else

      { writer.write( "\t" + paraTypeName + " v" + i //<mxiong debug 20060425 + " = pIWSDZ->" // + " = *(pIWSDZ->" //>mxiong debug 20060425 + CUtils.getParameterGetValueMethodName( paraTypeName, false) + "(\"" + elementName // <mxiong debug 20060425 // + "\",0));\n"); + "\",0);\n"); // >mxiong debug 20060425 }

      So I think it's a bug.

      [other]
      I will create a patch for you and upload it later.

        Activity

        Hide
        Michael Xiong added a comment -

        Sorry, the "Environment info" of this bug report is wrong, so should be corrected like the below:
        Platform:
        Linux fedora 3.0
        Axis version:
        Server-side Axis C++ 1.6Beta
        XML Parser Lib:
        xersesc 2.6
        WSDL2ws tool by using axis java 1.3
        Client-side version Axis java 1.3
        Http Server Version:
        Apache 2.0.53
        Tomcat 2.0.58

        Show
        Michael Xiong added a comment - Sorry, the "Environment info" of this bug report is wrong, so should be corrected like the below: Platform: Linux fedora 3.0 Axis version: Server-side Axis C++ 1.6Beta XML Parser Lib: xersesc 2.6 WSDL2ws tool by using axis java 1.3 Client-side version Axis java 1.3 Http Server Version: Apache 2.0.53 Tomcat 2.0.58
        Hide
        Michael Xiong added a comment -

        Hi Adrian Dick,

        Would you like to help me to correct the "Environment info" about this bug report like I commented above ?

        Thanks.
        Michael Xiong

        Show
        Michael Xiong added a comment - Hi Adrian Dick, Would you like to help me to correct the "Environment info" about this bug report like I commented above ? Thanks. Michael Xiong
        Hide
        Adrian Dick added a comment -

        Hi,

        I agree this code doens't look right ... would it be possible to attach your WSDL file so we can reproduce the problem you're seeing, and also validate your suggested fix.

        Have you tried the latest nightly builds, as there have been some recent changes in this area which may potentially have resolved this problem.

        Thanks,
        Adrian

        Show
        Adrian Dick added a comment - Hi, I agree this code doens't look right ... would it be possible to attach your WSDL file so we can reproduce the problem you're seeing, and also validate your suggested fix. Have you tried the latest nightly builds, as there have been some recent changes in this area which may potentially have resolved this problem. Thanks, Adrian
        Hide
        Jean Vincent added a comment -

        I have reproduced the issue,with this WSDL extract (complexType MTM generating MTM.cpp):
        <xsd:complexType name="MTM">
        <xsd:complexContent>
        <xsd:extension xmlns:tp="java:com.hidden"
        base="tp:DataElement">
        <xsd:sequence>
        <xsd:element name="MTM_MTM_DSD"
        maxOccurs="1"
        type="xsd:int"
        minOccurs="1"
        nillable="true">
        </xsd:element>
        <xsd:element name="FAM_ASS_MAC"
        maxOccurs="1"
        type="xsd:string"
        minOccurs="1"
        nillable="true">
        </xsd:element>
        <xsd:element name="MTM_MTM_NAT"
        maxOccurs="1"
        type="xsd:string"
        minOccurs="1"
        nillable="true">
        </xsd:element>
        <xsd:element name="MTM_MTM_DSF"
        maxOccurs="1"
        type="xsd:int"
        minOccurs="1"
        nillable="true">
        </xsd:element>
        </xsd:sequence>
        </xsd:extension>
        </xsd:complexContent>
        </xsd:complexType>

        Generates the code:
        int Axis_DeSerialize_MTM(MTM* param, IWrapperSoapDeSerializer* pIWSDZ)

        { xsd__int* p_MTM_MTM_DSD = (pIWSDZ->getElementAsInt("MTM_MTM_DSD",0)); param->MTM_MTM_DSD = *p_MTM_MTM_DSD; delete p_MTM_MTM_DSD; xsd__string* p_FAM_ASS_MAC = (pIWSDZ->getElementAsString("FAM_ASS_MAC",0)); param->FAM_ASS_MAC = *p_FAM_ASS_MAC; delete p_FAM_ASS_MAC; xsd__string* p_MTM_MTM_NAT = (pIWSDZ->getElementAsString("MTM_MTM_NAT",0)); param->MTM_MTM_NAT = *p_MTM_MTM_NAT; delete p_MTM_MTM_NAT; xsd__int* p_MTM_MTM_DSF = (pIWSDZ->getElementAsInt("MTM_MTM_DSF",0)); param->MTM_MTM_DSF = *p_MTM_MTM_DSF; delete p_MTM_MTM_DSF; return pIWSDZ->getStatus(); }

        Should have been (!!! in front of modified lines, 4 lines removed):
        int Axis_DeSerialize_MTM(MTM* param, IWrapperSoapDeSerializer* pIWSDZ)

        { xsd__int* p_MTM_MTM_DSD = (pIWSDZ->getElementAsInt("MTM_MTM_DSD",0)); param->MTM_MTM_DSD = *p_MTM_MTM_DSD; delete p_MTM_MTM_DSD; !!! param->FAM_ASS_MAC = pIWSDZ->getElementAsString("FAM_ASS_MAC",1); !!! param->MTM_MTM_NAT = pIWSDZ->getElementAsString("MTM_MTM_NAT",1); xsd__int* p_MTM_MTM_DSF = (pIWSDZ->getElementAsInt("MTM_MTM_DSF",0)); param->MTM_MTM_DSF = *p_MTM_MTM_DSF; delete p_MTM_MTM_DSF; return pIWSDZ->getStatus(); }

        The problem comes from the mis-handling of the nillable="true" attribute value in the WSDL in the code line 661 in writeDeSerializeGlobalMethod at src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java:
        if (attribs[i].isNillable()

        attribs[i].getTypeName().equals("xsd__anyURI")
        attribs[i].getTypeName().equals("xsd__QName")
        attribs[i].getTypeName().equals("xsd__NOTATION")) { //TODO handle optional attributes writer.write("\t" + attribs[i].getTypeName() + "* p_" + attribs[i].getParamNameAsMember() + " = (pIWSDZ->" + CUtils.getParameterGetValueMethodName(attribs[i] .getTypeName(), attribs[i].isAttribute()) + "(\"" + attribs[i].getParamName() + "\",0));\n"); writer.write("\tparam->" + attribs[i].getParamNameAsMember() + " = *p_" + attribs[i].getParamNameAsMember() + ";\n"); writer.write("\tdelete p_" + attribs[i].getParamNameAsMember() + ";\n"); }

        else if (attribs[i].getTypeName().equals("xsd__string")

        isElementNillable) { writer.write("\tparam->" + attribs[i].getParamNameAsMember() + " = pIWSDZ->" + CUtils.getParameterGetValueMethodName(attribs[i] .getTypeName(), attribs[i].isAttribute()) + "(\"" + attribs[i].getParamName() + "\",0);\n"); }

        The problem is the that isNillable() test get precedence over getTypeName().equals("xsd__string") and hence generates the wrong code with the additional pointer reference and superflous delete.

        This code has lots of TODO and probably much more issues, needs serious work and should be considered alpha code.

        Show
        Jean Vincent added a comment - I have reproduced the issue,with this WSDL extract (complexType MTM generating MTM.cpp): <xsd:complexType name="MTM"> <xsd:complexContent> <xsd:extension xmlns:tp="java:com.hidden" base="tp:DataElement"> <xsd:sequence> <xsd:element name="MTM_MTM_DSD" maxOccurs="1" type="xsd:int" minOccurs="1" nillable="true"> </xsd:element> <xsd:element name="FAM_ASS_MAC" maxOccurs="1" type="xsd:string" minOccurs="1" nillable="true"> </xsd:element> <xsd:element name="MTM_MTM_NAT" maxOccurs="1" type="xsd:string" minOccurs="1" nillable="true"> </xsd:element> <xsd:element name="MTM_MTM_DSF" maxOccurs="1" type="xsd:int" minOccurs="1" nillable="true"> </xsd:element> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> Generates the code: int Axis_DeSerialize_MTM(MTM* param, IWrapperSoapDeSerializer* pIWSDZ) { xsd__int* p_MTM_MTM_DSD = (pIWSDZ->getElementAsInt("MTM_MTM_DSD",0)); param->MTM_MTM_DSD = *p_MTM_MTM_DSD; delete p_MTM_MTM_DSD; xsd__string* p_FAM_ASS_MAC = (pIWSDZ->getElementAsString("FAM_ASS_MAC",0)); param->FAM_ASS_MAC = *p_FAM_ASS_MAC; delete p_FAM_ASS_MAC; xsd__string* p_MTM_MTM_NAT = (pIWSDZ->getElementAsString("MTM_MTM_NAT",0)); param->MTM_MTM_NAT = *p_MTM_MTM_NAT; delete p_MTM_MTM_NAT; xsd__int* p_MTM_MTM_DSF = (pIWSDZ->getElementAsInt("MTM_MTM_DSF",0)); param->MTM_MTM_DSF = *p_MTM_MTM_DSF; delete p_MTM_MTM_DSF; return pIWSDZ->getStatus(); } Should have been (!!! in front of modified lines, 4 lines removed): int Axis_DeSerialize_MTM(MTM* param, IWrapperSoapDeSerializer* pIWSDZ) { xsd__int* p_MTM_MTM_DSD = (pIWSDZ->getElementAsInt("MTM_MTM_DSD",0)); param->MTM_MTM_DSD = *p_MTM_MTM_DSD; delete p_MTM_MTM_DSD; !!! param->FAM_ASS_MAC = pIWSDZ->getElementAsString("FAM_ASS_MAC",1); !!! param->MTM_MTM_NAT = pIWSDZ->getElementAsString("MTM_MTM_NAT",1); xsd__int* p_MTM_MTM_DSF = (pIWSDZ->getElementAsInt("MTM_MTM_DSF",0)); param->MTM_MTM_DSF = *p_MTM_MTM_DSF; delete p_MTM_MTM_DSF; return pIWSDZ->getStatus(); } The problem comes from the mis-handling of the nillable="true" attribute value in the WSDL in the code line 661 in writeDeSerializeGlobalMethod at src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java: if (attribs [i] .isNillable() attribs [i] .getTypeName().equals("xsd__anyURI") attribs [i] .getTypeName().equals("xsd__QName") attribs [i] .getTypeName().equals("xsd__NOTATION")) { //TODO handle optional attributes writer.write("\t" + attribs[i].getTypeName() + "* p_" + attribs[i].getParamNameAsMember() + " = (pIWSDZ->" + CUtils.getParameterGetValueMethodName(attribs[i] .getTypeName(), attribs[i].isAttribute()) + "(\"" + attribs[i].getParamName() + "\",0));\n"); writer.write("\tparam->" + attribs[i].getParamNameAsMember() + " = *p_" + attribs[i].getParamNameAsMember() + ";\n"); writer.write("\tdelete p_" + attribs[i].getParamNameAsMember() + ";\n"); } else if (attribs [i] .getTypeName().equals("xsd__string") isElementNillable ) { writer.write("\tparam->" + attribs[i].getParamNameAsMember() + " = pIWSDZ->" + CUtils.getParameterGetValueMethodName(attribs[i] .getTypeName(), attribs[i].isAttribute()) + "(\"" + attribs[i].getParamName() + "\",0);\n"); } The problem is the that isNillable() test get precedence over getTypeName().equals("xsd__string") and hence generates the wrong code with the additional pointer reference and superflous delete. This code has lots of TODO and probably much more issues, needs serious work and should be considered alpha code.
        Hide
        Jean Vincent added a comment -

        The same bug is in several places, according to initial submission it is at least also in:
        src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/WrapWriter.java

        Ideally we should avoid to duplicate code as much as possible to help fixing at single locations.

        I don't know if this is in other files. The problem lies with the use of isNillable() so this might help to locate the other locations for this bug.

        Show
        Jean Vincent added a comment - The same bug is in several places, according to initial submission it is at least also in: src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/WrapWriter.java Ideally we should avoid to duplicate code as much as possible to help fixing at single locations. I don't know if this is in other files. The problem lies with the use of isNillable() so this might help to locate the other locations for this bug.
        Hide
        Jean Vincent added a comment -

        Here is the list of files using isNillable()

        1. find src/wsdl/org/apache/axis/wsdl/wsdl2ws -name '*java' | xargs grep -l isNillable
          src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/BeanParamWriter.java
          src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubHeaderWriter.java
          src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/WrapWriter.java
          src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java
          src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/WrapWriter.java
          src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ServiceWriter.java
          src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java
          src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubHeaderWriter.java
          src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java
          src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ServiceHeaderWriter.java
          src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java
          src/wsdl/org/apache/axis/wsdl/wsdl2ws/ParamWriter.java
          src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/ParameterInfo.java
          src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java
          #
        Show
        Jean Vincent added a comment - Here is the list of files using isNillable() find src/wsdl/org/apache/axis/wsdl/wsdl2ws -name '*java' | xargs grep -l isNillable src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/BeanParamWriter.java src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubHeaderWriter.java src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/WrapWriter.java src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/WrapWriter.java src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ServiceWriter.java src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubHeaderWriter.java src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ServiceHeaderWriter.java src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java src/wsdl/org/apache/axis/wsdl/wsdl2ws/ParamWriter.java src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/ParameterInfo.java src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java #
        Hide
        Jean Vincent added a comment -

        A similar problem with xsd_int when the parameter is nillable. In the generate code above it should have generated:
        Should have been (!!! in front of modified lines, 8 lines removed):
        int Axis_DeSerialize_MTM(MTM* param, IWrapperSoapDeSerializer* pIWSDZ)

        { !!! param->MTM_MTM_DSD = pIWSDZ->getElementAsInt("MTM_MTM_DSD",0); !!! param->FAM_ASS_MAC = pIWSDZ->getElementAsString("FAM_ASS_MAC",1); !!! param->MTM_MTM_NAT = pIWSDZ->getElementAsString("MTM_MTM_NAT",1); !!! param->MTM_MTM_DSF = pIWSDZ->getElementAsInt("MTM_MTM_DSF",0); return pIWSDZ->getStatus(); }

        Note that if the xsd_int was not nillable the generated code would be correct by assigning the integer value and deleting the allocated xsd_int*. But when the last xsd_int is nillable, and the value is now stored as an xsd_int*, it should be assigned by reference and not deleted.

        I believe the same issue probably comes with all nillable types.

        Show
        Jean Vincent added a comment - A similar problem with xsd_int when the parameter is nillable. In the generate code above it should have generated: Should have been (!!! in front of modified lines, 8 lines removed): int Axis_DeSerialize_MTM(MTM* param, IWrapperSoapDeSerializer* pIWSDZ) { !!! param->MTM_MTM_DSD = pIWSDZ->getElementAsInt("MTM_MTM_DSD",0); !!! param->FAM_ASS_MAC = pIWSDZ->getElementAsString("FAM_ASS_MAC",1); !!! param->MTM_MTM_NAT = pIWSDZ->getElementAsString("MTM_MTM_NAT",1); !!! param->MTM_MTM_DSF = pIWSDZ->getElementAsInt("MTM_MTM_DSF",0); return pIWSDZ->getStatus(); } Note that if the xsd_int was not nillable the generated code would be correct by assigning the integer value and deleting the allocated xsd_ int*. But when the last xsd_int is nillable, and the value is now stored as an xsd _int*, it should be assigned by reference and not deleted. I believe the same issue probably comes with all nillable types.
        Hide
        Michael Xiong added a comment -

        Dear all,

        Environment:
        Tomcat 2.0.58 should be -->
        Tomcat 5.0.28

        Could someboday help me to update the "Environment:" info ?

        Thanks a lot !
        Michael Xiong

        Show
        Michael Xiong added a comment - Dear all, Environment: Tomcat 2.0.58 should be --> Tomcat 5.0.28 Could someboday help me to update the "Environment:" info ? Thanks a lot ! Michael Xiong
        Hide
        nadir amra added a comment -

        I need a sample wsdl file to resolve this problem.

        Show
        nadir amra added a comment - I need a sample wsdl file to resolve this problem.
        Hide
        Matthew Metke added a comment -

        https://issues.apache.org/jira/rpc/soap/jirasoapservice-v2?wsdl

        I'm trying to write a SOAP interface to Jira in C++ and I am running in to this and other problems.

        xsd__string* p_id = (pIWSDZ->getElementAsString("id",0));
        param->id = *p_id;
        delete p_id;

        As demonstrated above. In addition, I don't think the delete should be there and really the whole thing could be just
        param->id = (pIWSDZ->getElementAsString("id",0));

        Show
        Matthew Metke added a comment - https://issues.apache.org/jira/rpc/soap/jirasoapservice-v2?wsdl I'm trying to write a SOAP interface to Jira in C++ and I am running in to this and other problems. xsd__string* p_id = (pIWSDZ->getElementAsString("id",0)); param->id = *p_id; delete p_id; As demonstrated above. In addition, I don't think the delete should be there and really the whole thing could be just param->id = (pIWSDZ->getElementAsString("id",0));
        Hide
        nadir amra added a comment -

        I believe the initial issue is fixed. The resolution resulted in code change from:
        ============
        if (param.isNillable() &&
        !(CUtils.isPointerType(type.getLanguageSpecificName())))

        { writer.write("\t" + paraTypeName + "* v" + i + " = pIWSDZ->" + CUtils.getParameterGetValueMethodName(paraTypeName,false) + "(\"" + elementName + "\",0);\n"); }

        else

        { writer.write("\t" + paraTypeName + " v" + i + " = *(pIWSDZ->" + CUtils.getParameterGetValueMethodName(paraTypeName,false) + "(\"" + elementName + "\",0));\n"); }

        ==============
        TO
        ==============
        String splatPtr = " ";
        String splatDeref = " ";

        if (!CUtils.isPointerType(type.getLanguageSpecificName()))

        { if (param.isNillable() || param.isOptional()) splatPtr = " * "; else splatDeref = " * "; }

        writer.write("\t" + paraTypeName + splatPtr + "v" + i + " =" + splatDeref
        + "(pIWSDZ->" + CUtils.getParameterGetValueMethodName(paraTypeName,false)
        + "(\"" + elementName + "\",0));\n");

        ==============
        Let us know if there are any problems. The other issues included in this JIRA, I believe, are resolved. If not, please open a new JIRA describing the problem.

        Show
        nadir amra added a comment - I believe the initial issue is fixed. The resolution resulted in code change from: ============ if (param.isNillable() && !(CUtils.isPointerType(type.getLanguageSpecificName()))) { writer.write("\t" + paraTypeName + "* v" + i + " = pIWSDZ->" + CUtils.getParameterGetValueMethodName(paraTypeName,false) + "(\"" + elementName + "\",0);\n"); } else { writer.write("\t" + paraTypeName + " v" + i + " = *(pIWSDZ->" + CUtils.getParameterGetValueMethodName(paraTypeName,false) + "(\"" + elementName + "\",0));\n"); } ============== TO ============== String splatPtr = " "; String splatDeref = " "; if (!CUtils.isPointerType(type.getLanguageSpecificName())) { if (param.isNillable() || param.isOptional()) splatPtr = " * "; else splatDeref = " * "; } writer.write("\t" + paraTypeName + splatPtr + "v" + i + " =" + splatDeref + "(pIWSDZ->" + CUtils.getParameterGetValueMethodName(paraTypeName,false) + "(\"" + elementName + "\",0));\n"); ============== Let us know if there are any problems. The other issues included in this JIRA, I believe, are resolved. If not, please open a new JIRA describing the problem.

          People

          • Assignee:
            Unassigned
            Reporter:
            Michael Xiong
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development