You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by Nadine Maloney <Na...@microfocus.com> on 2004/03/22 16:51:57 UTC

Axis for C++ Bug

Hello,

I just downloaded Axis fo C++ to look into using it for out company's
product. We just need to creat a C++ SOAP client. I have found a bug in the
source that I downloaded on 3-15-2004. The bug has to do with parsing the
response from the server. An example of a response from the server follows.

<?xml version="1.0" encoding="UTF-8"?>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/

< <http://schemas.xmlsoap.org/soap/envelope/>
http://schemas.xmlsoap.org/soap/envelope/> "
xmlns:xsd="http://www.w3.org/2001/XMLSchema

< <http://www.w3.org/2001/XMLSchema> http://www.w3.org/2001/XMLSchema> " 

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance

< <http://www.w3.org/2001/XMLSchema-instance>
http://www.w3.org/2001/XMLSchema-instance> ">

<soapenv:Body>

<ns1:getApplicationsResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/

< <http://schemas.xmlsoap.org/soap/encoding/>
http://schemas.xmlsoap.org/soap/encoding/> " 

xmlns:ns1="DbService">

<ns1:getApplicationsReturn xsi:type="xsd:string">

&lt;applications typename=&quot;T_USER_APPLICATION&quot; 

typenum=&quot;1153414086084526080&quot;

typelabel=&quot;Application&quot;&gt;

&lt;app eid=&quot;-268&quot; name=&quot;SYSTEM.IBM&quot;/&gt;

&lt;/applications&gt;

</ns1:getApplicationsReturn>

</ns1:getApplicationsResponse>

</soapenv:Body>

</soapenv:Envelope>

The result string returned by the following statement created in the stub
classes from the WSDL 

m_pCall->GetResult()->GetString(&Ret);

is ">".

After building the Axis C++ classes in debug mode and stepping through the
code, I found that the characters method of XMLStreamHandler class is called
multiple times for the text from the ns1:getApplicationsReturn tag. The text
appears to be broken apart by the '&' character. The "&lt;" type characters
are being translated correctly to "<" in the text passed to the characters
method. The bug is that for each call the m_sValue in the m_Param of the
Param class variable is being overwritten with the last text handed to the
characters method. Therefore only returning the last character in the text
of ">". It appears that the characters method does not handle multiple calls
for the text of the same element tag.

I was wondering if this bug had been reported and fixed? I did provide a fix
the version I have been using by adding the following statement to
XMLStreamHandler::SetParamType to the beginning of the method. This resets
the string value for the parameter when each new element is started.

m_Param.m_sValue = "";

I also changed the Param::SetValue method to the following.

int Param::SetValue(const AxisChar* sValue)

{

AxisChar* endptr = NULL;

if (strlen(sValue) == 0) return AXIS_FAIL;

switch (m_Type)

{

case XSD_INT:

m_Value.nValue = strtol(sValue, &endptr, 10);

m_sValue = sValue; 

break;

case XSD_UNSIGNEDINT:

m_Value.nValue = strtoul(sValue, &endptr, 10);

m_sValue = sValue; 

break;

case XSD_SHORT:

m_Value.sValue = strtol(sValue, &endptr, 10);

m_sValue = sValue; 

break;

case XSD_UNSIGNEDSHORT:

m_Value.usValue = strtoul(sValue, &endptr, 10);

m_sValue = sValue; 

break;

case XSD_BYTE:

m_Value.cValue = strtol(sValue, &endptr, 10);

m_sValue = sValue; 

break;

case XSD_UNSIGNEDBYTE:

m_Value.ucValue = strtoul(sValue, &endptr, 10);

m_sValue = sValue; 

break; 

case XSD_LONG:

case XSD_INTEGER:

m_Value.lValue = strtol(sValue, &endptr, 10);

m_sValue = sValue; 

break; 

case XSD_UNSIGNEDLONG:

m_Value.ulValue = strtoul(sValue, &endptr, 10);

m_sValue = sValue; 

break; 

case XSD_FLOAT:

m_Value.fValue = strtod(sValue, &endptr);

m_sValue = sValue; 

break;

case XSD_DOUBLE:

case XSD_DECIMAL:

m_Value.dValue = strtod(sValue, &endptr);

m_sValue = sValue; 

break; 

case XSD_STRING:

case XSD_HEXBINARY:

case XSD_BASE64BINARY:

case XSD_ANYURI:

case XSD_QNAME:

case XSD_NOTATION: 

m_sValue.append(sValue);

break;

case XSD_DATETIME:

case XSD_DATE:

case XSD_TIME:

m_Value.tValue = AxisTime::Deserialize(sValue, m_Type);

m_sValue = sValue; 

break; 

case XSD_DURATION:

m_Value.lDuration = AxisTime::DeserializeDuration(sValue,

m_Type);

m_sValue = sValue; 

break;

//Continue this for all basic types

case XSD_ARRAY:

case USER_TYPE:

return AXIS_FAIL;

default:

return AXIS_FAIL; //this is an unexpected situation

}

if (endptr && (strlen(endptr) > 0)) return AXIS_FAIL; //a string to number
conversion is attempted and failed

return AXIS_SUCCESS;

}

This keeps appending the value for a string text to the end of s_mValue.
This seems to have fixed the problem, but I am not sure if it broke anything
else. It has been working for me for several days while I have played with
the libraries.

Nadine Maloney

Senior Software Engineer

Micro Focus


Re: Axis for C++ Bug

Posted by su...@opensource.lk.
Hi Nadine Maloney,

Yes there was a bug in Axis C++ 1.0 like what you describe below. But that
cannot be there in the sources downloaded on 3-15-2004.

In the latest code we dont use either XMLStreamHandler class or
Param::SetValue(const AxisChar* sValue) functionality.

Instead we use expat parser.

Please check this problem in the latest code and it you find it again let
me know.

Thanks,

Susantha.

> Hello,
>
> I just downloaded Axis fo C++ to look into using it for out company's
> product. We just need to creat a C++ SOAP client. I have found a bug in
> the
> source that I downloaded on 3-15-2004. The bug has to do with parsing the
> response from the server. An example of a response from the server
> follows.
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/
>
> < <http://schemas.xmlsoap.org/soap/envelope/>
> http://schemas.xmlsoap.org/soap/envelope/> "
> xmlns:xsd="http://www.w3.org/2001/XMLSchema
>
> < <http://www.w3.org/2001/XMLSchema> http://www.w3.org/2001/XMLSchema> "
>
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
>
> < <http://www.w3.org/2001/XMLSchema-instance>
> http://www.w3.org/2001/XMLSchema-instance> ">
>
> <soapenv:Body>
>
> <ns1:getApplicationsResponse
> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/
>
> < <http://schemas.xmlsoap.org/soap/encoding/>
> http://schemas.xmlsoap.org/soap/encoding/> "
>
> xmlns:ns1="DbService">
>
> <ns1:getApplicationsReturn xsi:type="xsd:string">
>
> <applications typename="T_USER_APPLICATION"
>
> typenum="1153414086084526080"
>
> typelabel="Application">
>
> <app eid="-268" name="SYSTEM.IBM"/>
>
> </applications>
>
> </ns1:getApplicationsReturn>
>
> </ns1:getApplicationsResponse>
>
> </soapenv:Body>
>
> </soapenv:Envelope>
>
> The result string returned by the following statement created in the stub
> classes from the WSDL
>
> m_pCall->GetResult()->GetString(&Ret);
>
> is ">".
>
> After building the Axis C++ classes in debug mode and stepping through the
> code, I found that the characters method of XMLStreamHandler class is
> called
> multiple times for the text from the ns1:getApplicationsReturn tag. The
> text
> appears to be broken apart by the '&' character. The "<" type
> characters
> are being translated correctly to "<" in the text passed to the characters
> method. The bug is that for each call the m_sValue in the m_Param of the
> Param class variable is being overwritten with the last text handed to the
> characters method. Therefore only returning the last character in the text
> of ">". It appears that the characters method does not handle multiple
> calls
> for the text of the same element tag.
>
> I was wondering if this bug had been reported and fixed? I did provide a
> fix
> the version I have been using by adding the following statement to
> XMLStreamHandler::SetParamType to the beginning of the method. This resets
> the string value for the parameter when each new element is started.
>
> m_Param.m_sValue = "";
>
> I also changed the Param::SetValue method to the following.
>
> int Param::SetValue(const AxisChar* sValue)
>
> {
>
> AxisChar* endptr = NULL;
>
> if (strlen(sValue) == 0) return AXIS_FAIL;
>
> switch (m_Type)
>
> {
>
> case XSD_INT:
>
> m_Value.nValue = strtol(sValue, &endptr, 10);
>
> m_sValue = sValue;
>
> break;
>
> case XSD_UNSIGNEDINT:
>
> m_Value.nValue = strtoul(sValue, &endptr, 10);
>
> m_sValue = sValue;
>
> break;
>
> case XSD_SHORT:
>
> m_Value.sValue = strtol(sValue, &endptr, 10);
>
> m_sValue = sValue;
>
> break;
>
> case XSD_UNSIGNEDSHORT:
>
> m_Value.usValue = strtoul(sValue, &endptr, 10);
>
> m_sValue = sValue;
>
> break;
>
> case XSD_BYTE:
>
> m_Value.cValue = strtol(sValue, &endptr, 10);
>
> m_sValue = sValue;
>
> break;
>
> case XSD_UNSIGNEDBYTE:
>
> m_Value.ucValue = strtoul(sValue, &endptr, 10);
>
> m_sValue = sValue;
>
> break;
>
> case XSD_LONG:
>
> case XSD_INTEGER:
>
> m_Value.lValue = strtol(sValue, &endptr, 10);
>
> m_sValue = sValue;
>
> break;
>
> case XSD_UNSIGNEDLONG:
>
> m_Value.ulValue = strtoul(sValue, &endptr, 10);
>
> m_sValue = sValue;
>
> break;
>
> case XSD_FLOAT:
>
> m_Value.fValue = strtod(sValue, &endptr);
>
> m_sValue = sValue;
>
> break;
>
> case XSD_DOUBLE:
>
> case XSD_DECIMAL:
>
> m_Value.dValue = strtod(sValue, &endptr);
>
> m_sValue = sValue;
>
> break;
>
> case XSD_STRING:
>
> case XSD_HEXBINARY:
>
> case XSD_BASE64BINARY:
>
> case XSD_ANYURI:
>
> case XSD_QNAME:
>
> case XSD_NOTATION:
>
> m_sValue.append(sValue);
>
> break;
>
> case XSD_DATETIME:
>
> case XSD_DATE:
>
> case XSD_TIME:
>
> m_Value.tValue = AxisTime::Deserialize(sValue, m_Type);
>
> m_sValue = sValue;
>
> break;
>
> case XSD_DURATION:
>
> m_Value.lDuration = AxisTime::DeserializeDuration(sValue,
>
> m_Type);
>
> m_sValue = sValue;
>
> break;
>
> //Continue this for all basic types
>
> case XSD_ARRAY:
>
> case USER_TYPE:
>
> return AXIS_FAIL;
>
> default:
>
> return AXIS_FAIL; //this is an unexpected situation
>
> }
>
> if (endptr && (strlen(endptr) > 0)) return AXIS_FAIL; //a string to number
> conversion is attempted and failed
>
> return AXIS_SUCCESS;
>
> }
>
> This keeps appending the value for a string text to the end of s_mValue.
> This seems to have fixed the problem, but I am not sure if it broke
> anything
> else. It has been working for me for several days while I have played with
> the libraries.
>
> Nadine Maloney
>
> Senior Software Engineer
>
> Micro Focus
>
>