You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Ronny Weiser <Ro...@meta-1.com> on 2005/09/21 09:46:19 UTC

UTF-16 encoded return value

Hi,

we are using axis 1.2.1 on tomcat 5.x. Some of our services return an utf-16
encoded xml string. We have set the parameter "axis.xmlEncoding" in the
server-config.wsdd to "UTF-16", but when building the soap message, axis
throws an exception:

Client receives something like that:
java.lang.IllegalArgumentException: The char '0x0' in
'java.lang.IllegalArgumentException: The char '0x0' in 'ÿþ&lt;
...

The stacktrace in a testcase:
at org.apache.axis.components.encoding.AbstractXMLEncoder.encode
(AbstractXMLEncoder.java:110)
at org.apache.axis.utils.XMLUtils.xmlEncodeString(XMLUtils.java:131)
at org.apache.axis.utils.DOM2Writer.normalize(DOM2Writer.java:344)
at org.apache.axis.utils.DOM2Writer.print(DOM2Writer.java:246)
at org.apache.axis.utils.DOM2Writer.print(DOM2Writer.java:208)
at org.apache.axis.utils.DOM2Writer.serializeAsXML(DOM2Writer.java:77)
at org.apache.axis.utils.DOM2Writer.serializeAsXML(DOM2Writer.java:60)
at org.apache.axis.utils.DOM2Writer.nodeToString(DOM2Writer.java:49)
at org.apache.axis.utils.XMLUtils.privateElementToString(XMLUtils.java:433)
at org.apache.axis.utils.XMLUtils.ElementToString(XMLUtils.java:442)
at org.apache.axis.utils.XMLUtils.getInnerXMLString(XMLUtils.java:542)

To transform our xml to utf-16 we use the following:
...
TransformerFactory trafoFactory = TransformerFactory.newInstance();
transformer = trafoFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "no");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-16");
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, "no");
transformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, "no");
transformer.transform(new DOMSource(doc), new StreamResult(out)); 
...

We use the transformer from java.xml.transform and the document buider from
java.xml.parsers

Is there anything I can do to force axis to accept our utf-16 xml string or
is there a different possibility? The fact is we need utf-16.

Thanks,

Ronny Weiser  



Re: UTF-16 encoded return value

Posted by Davanum Srinivas <da...@gmail.com>.
Please log a bug with your sample code.

thanks,
dims

On 9/21/05, Ronny Weiser <Ro...@meta-1.com> wrote:
> Hi,
>
> we are using axis 1.2.1 on tomcat 5.x. Some of our services return an utf-16
> encoded xml string. We have set the parameter "axis.xmlEncoding" in the
> server-config.wsdd to "UTF-16", but when building the soap message, axis
> throws an exception:
>
> Client receives something like that:
> java.lang.IllegalArgumentException: The char '0x0' in
> 'java.lang.IllegalArgumentException: The char '0x0' in 'ÿþ&lt;
> ...
>
> The stacktrace in a testcase:
> at org.apache.axis.components.encoding.AbstractXMLEncoder.encode
> (AbstractXMLEncoder.java:110)
> at org.apache.axis.utils.XMLUtils.xmlEncodeString(XMLUtils.java:131)
> at org.apache.axis.utils.DOM2Writer.normalize(DOM2Writer.java:344)
> at org.apache.axis.utils.DOM2Writer.print(DOM2Writer.java:246)
> at org.apache.axis.utils.DOM2Writer.print(DOM2Writer.java:208)
> at org.apache.axis.utils.DOM2Writer.serializeAsXML(DOM2Writer.java:77)
> at org.apache.axis.utils.DOM2Writer.serializeAsXML(DOM2Writer.java:60)
> at org.apache.axis.utils.DOM2Writer.nodeToString(DOM2Writer.java:49)
> at org.apache.axis.utils.XMLUtils.privateElementToString(XMLUtils.java:433)
> at org.apache.axis.utils.XMLUtils.ElementToString(XMLUtils.java:442)
> at org.apache.axis.utils.XMLUtils.getInnerXMLString(XMLUtils.java:542)
>
> To transform our xml to utf-16 we use the following:
> ...
> TransformerFactory trafoFactory = TransformerFactory.newInstance();
> transformer = trafoFactory.newTransformer();
> transformer.setOutputProperty(OutputKeys.INDENT, "no");
> transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-16");
> transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
> transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, "no");
> transformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, "no");
> transformer.transform(new DOMSource(doc), new StreamResult(out));
> ...
>
> We use the transformer from java.xml.transform and the document buider from
> java.xml.parsers
>
> Is there anything I can do to force axis to accept our utf-16 xml string or
> is there a different possibility? The fact is we need utf-16.
>
> Thanks,
>
> Ronny Weiser
>
>
>


--
Davanum Srinivas : http://wso2.com/ - Oxygenating The Web Service Platform