You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by Iwan Tomlow <iw...@seagha.com> on 2006/05/15 14:34:04 UTC

Crash in XercesHandler.cpp with & in response

Hi all,

I'm using the Axis C++ 1.5 in a production project, and we are
experiencing problems when the response from the webservice contains
ampersands in the xml-data, like <name>BOOT & BUTEIJN</name>.

The generated Axis-client stub crashes (with 'Invalid Address specified
to RtlFreeHeap' in MCVC6.0 debugger) on the following code in
XercesHandler::characters
>>>	free(const_cast <char*> (cp_PreviousNameOrValue));
	free(cp_CurrentNameOrValue);

I found a jira-issue (AXISCPP-825) that seems to address this issue, but
the reported fix (change free to delete[]) does not work for me, the
result is the same.

Does anyone have this issue, any hints?
Strange thing: it appears everything works fine if a point my XMLParser
in axiscpp.conf to the debug-library 'AxisXMLParser_D.dll' instead of
the release-build, but I'm afraid that is just a coincidence.

Any help appreciated.

Kind regards,
Iwan Tomlow

RE: Invalid byte 2 of 2-byte UTF-8 sequence?

Posted by Nadir Amra <am...@us.ibm.com>.
Iwan,

It would be a fix if you were running only in a process that is consistent 
with ISO-8859-1 encoding, but that is not the case.  From the client-side, 
the easiest fix would be to provide a  toUTF8() function as OS/400 does. 
The proper fix for client/server side is to ensure all data stored in 
various classes is wchar and to translate wchar to utf8. 
 
Nadir K. Amra


"Iwan Tomlow" <iw...@seagha.com> wrote on 03/29/2007 09:04:32 AM:

> Thanks for pointing that out, I should have been able to find that one 
myself.
> Most reasonable thing for me to do seems to apply the proposed 
> workaround from AXISCPP-964, i.e.
> 
> In SoapSerializer.cpp, turn
> serialize( "<?xml version='1.0' encoding='utf-8' ?>", NULL);
> into
> serialize( "<?xml version='1.0' encoding='ISO-8859-1' ?>", NULL); 
> 
> I'm no expert on character-encoding, but since "AxisChar" is defined
> in Gdefine.hpp as a normal "char" anyway, isn't this simply the best
> way to fix the issue completely?
> 
> Kind regards,
> Iwan
> 
> 
> -----Original Message-----
> From: Nadir Amra [mailto:amra@us.ibm.com] 
> Sent: donderdag 29 maart 2007 0:52
> To: Apache AXIS C User List
> Cc: Apache AXIS C User List
> Subject: Re: Invalid byte 2 of 2-byte UTF-8 sequence?
> 
> Iwan,
> 
> This is an existing problem.  See AXISCPP-964.  If anyone want to 
> provide a patch, I can include the patch. If you have a solution to 
> fix your particular problem, then please provide the patch. 
> 
> Nadir K. Amra
> 
> 
> "Iwan Tomlow" <iw...@seagha.com> wrote on 03/28/2007 06:22:00 AM:
> 
> > Hi,
> > 
> > when connecting an Axis-C client (v1.5) to an Axis-java webservice, 
> > the return message has the following error:
> > 
> > <soapenv:Fault>
> >   <faultcode>soapenv:Server.userException</faultcode>
> >    <faultstring>java.io.UTFDataFormatException: Invalid byte 2 of 2- 
> > byte UTF-8 sequence.</faultstring>
> > 
> > The only difference with all other working requests, seems the company 

> > name containing "GÜTER".
> > When debugging, the U-umlaut is showing correctly everywhere, but 
> > apparently the receiving webservice isn't getting it correctly.
> > The source message generated by Axis-C++ looks like this in 
TCPMonitor:
> > 
> > Content-Type: text/xml; charset=UTF-8
> > 
> > <?xml version='1.0' encoding='utf-8' ?> ...
> >                   <ns1:company>ROTTMANN HEINRICH G TER</ns1:company>
> > 
> > So it seems the character is indeed being encoded incorrectly by 
Axis-C?
> > 
> > 
> > Does anyone have any hints to get this working?
> > 
> > By the way, I receive this company-name via another webservice, and I 
> > notice that they sent me this:
> > 
> > <employerName>ROTTMANN HEINRICH G&#xDC;TER</employerName>
> > 
> > Maybe there is a way to configure Axis-C to do the same, sending a 
> > character reference to avoid the encoding-mismatch?
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-user-help@ws.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-user-help@ws.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org


RE: Invalid byte 2 of 2-byte UTF-8 sequence?

Posted by Iwan Tomlow <iw...@seagha.com>.
Thanks for pointing that out, I should have been able to find that one myself.
Most reasonable thing for me to do seems to apply the proposed workaround from AXISCPP-964, i.e.

In SoapSerializer.cpp, turn
serialize( "<?xml version='1.0' encoding='utf-8' ?>", NULL);
into
serialize( "<?xml version='1.0' encoding='ISO-8859-1' ?>", NULL);  

I'm no expert on character-encoding, but since "AxisChar" is defined in Gdefine.hpp as a normal "char" anyway, isn't this simply the best way to fix the issue completely?

Kind regards,
Iwan


-----Original Message-----
From: Nadir Amra [mailto:amra@us.ibm.com] 
Sent: donderdag 29 maart 2007 0:52
To: Apache AXIS C User List
Cc: Apache AXIS C User List
Subject: Re: Invalid byte 2 of 2-byte UTF-8 sequence?

Iwan,

This is an existing problem.  See AXISCPP-964.  If anyone want to provide a patch, I can include the patch. If you have a solution to fix your particular problem, then please provide the patch. 

Nadir K. Amra


"Iwan Tomlow" <iw...@seagha.com> wrote on 03/28/2007 06:22:00 AM:

> Hi,
> 
> when connecting an Axis-C client (v1.5) to an Axis-java webservice, 
> the return message has the following error:
> 
> <soapenv:Fault>
>   <faultcode>soapenv:Server.userException</faultcode>
>    <faultstring>java.io.UTFDataFormatException: Invalid byte 2 of 2- 
> byte UTF-8 sequence.</faultstring>
> 
> The only difference with all other working requests, seems the company 
> name containing "GÜTER".
> When debugging, the U-umlaut is showing correctly everywhere, but 
> apparently the receiving webservice isn't getting it correctly.
> The source message generated by Axis-C++ looks like this in TCPMonitor:
> 
> Content-Type: text/xml; charset=UTF-8
> 
> <?xml version='1.0' encoding='utf-8' ?> ...
>                   <ns1:company>ROTTMANN HEINRICH G TER</ns1:company>
> 
> So it seems the character is indeed being encoded incorrectly by Axis-C?
> 
> 
> Does anyone have any hints to get this working?
> 
> By the way, I receive this company-name via another webservice, and I 
> notice that they sent me this:
> 
> <employerName>ROTTMANN HEINRICH G&#xDC;TER</employerName>
> 
> Maybe there is a way to configure Axis-C to do the same, sending a 
> character reference to avoid the encoding-mismatch?


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org


Re: Invalid byte 2 of 2-byte UTF-8 sequence?

Posted by Nadir Amra <am...@us.ibm.com>.
Iwan,

This is an existing problem.  See AXISCPP-964.  If anyone want to provide 
a patch, I can include the patch. If you have a solution to fix your 
particular problem, then please provide the patch. 

Nadir K. Amra


"Iwan Tomlow" <iw...@seagha.com> wrote on 03/28/2007 06:22:00 AM:

> Hi,
> 
> when connecting an Axis-C client (v1.5) to an Axis-java webservice, 
> the return message has the following error:
> 
> <soapenv:Fault>
>   <faultcode>soapenv:Server.userException</faultcode>
>    <faultstring>java.io.UTFDataFormatException: Invalid byte 2 of 2-
> byte UTF-8 sequence.</faultstring>
> 
> The only difference with all other working requests, seems the 
> company name containing "GÜTER".
> When debugging, the U-umlaut is showing correctly everywhere, but 
> apparently the receiving webservice isn't getting it correctly.
> The source message generated by Axis-C++ looks like this in TCPMonitor:
> 
> Content-Type: text/xml; charset=UTF-8
> 
> <?xml version='1.0' encoding='utf-8' ?>
> ...
>                   <ns1:company>ROTTMANN HEINRICH G TER</ns1:company>
> 
> So it seems the character is indeed being encoded incorrectly by Axis-C?
> 
> 
> Does anyone have any hints to get this working?
> 
> By the way, I receive this company-name via another webservice, and 
> I notice that they sent me this:
> 
> <employerName>ROTTMANN HEINRICH G&#xDC;TER</employerName>
> 
> Maybe there is a way to configure Axis-C to do the same, sending a 
> character reference to avoid the encoding-mismatch?


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org


Invalid byte 2 of 2-byte UTF-8 sequence?

Posted by Iwan Tomlow <iw...@seagha.com>.
Hi,

when connecting an Axis-C client (v1.5) to an Axis-java webservice, the return message has the following error:

<soapenv:Fault>
  <faultcode>soapenv:Server.userException</faultcode>
   <faultstring>java.io.UTFDataFormatException: Invalid byte 2 of 2-byte UTF-8 sequence.</faultstring>

The only difference with all other working requests, seems the company name containing "GÜTER".
When debugging, the U-umlaut is showing correctly everywhere, but apparently the receiving webservice isn't getting it correctly.
The source message generated by Axis-C++ looks like this in TCPMonitor:

Content-Type: text/xml; charset=UTF-8

<?xml version='1.0' encoding='utf-8' ?>
...
                  <ns1:company>ROTTMANN HEINRICH G TER</ns1:company>

So it seems the character is indeed being encoded incorrectly by Axis-C?


Does anyone have any hints to get this working?

By the way, I receive this company-name via another webservice, and I notice that they sent me this:

<employerName>ROTTMANN HEINRICH G&#xDC;TER</employerName>

Maybe there is a way to configure Axis-C to do the same, sending a character reference to avoid the encoding-mismatch?

Kind regards,
Iwan Tomlow

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org


Re: Crash in XercesHandler.cpp with & in response

Posted by Adrian Dick <ad...@uk.ibm.com>.
Hi,


Under the SOAP (and underlying XML) standards the ampersand character is
reserved, so you are not permitted to use it within data.
You will need to ensure any occurances are correctly encoded   --- ie:  '&'
becomes "&amp;".

It looks quite likely the Xerces Parser is failing when it hits this
invalid use of '&'.

How is this XML data being produced?   Are you using xsd:any -- in which
case you'll need to ensure this encoding takes place -- or are you seeing
an error in the Axis serialization code, where this should be taking place
on your behalf.

Are you in a position to test if this problem is still present with the
latest Axis 1.6 nightly builds?

Regards,
Adrian
_______________________________________
Adrian Dick (adrian.dick@uk.ibm.com)


"Iwan Tomlow" <iw...@seagha.com> wrote on 15/05/2006 13:34:04:

> Hi all,
>
> I'm using the Axis C++ 1.5 in a production project, and we are
> experiencing problems when the response from the webservice contains
> ampersands in the xml-data, like <name>BOOT & BUTEIJN</name>.
>
> The generated Axis-client stub crashes (with 'Invalid Address specified
> to RtlFreeHeap' in MCVC6.0 debugger) on the following code in
> XercesHandler::characters
> >>>   free(const_cast <char*> (cp_PreviousNameOrValue));
>    free(cp_CurrentNameOrValue);
>
> I found a jira-issue (AXISCPP-825) that seems to address this issue, but
> the reported fix (change free to delete[]) does not work for me, the
> result is the same.
>
> Does anyone have this issue, any hints?
> Strange thing: it appears everything works fine if a point my XMLParser
> in axiscpp.conf to the debug-library 'AxisXMLParser_D.dll' instead of
> the release-build, but I'm afraid that is just a coincidence.
>
> Any help appreciated.
>
> Kind regards,
> Iwan Tomlow