Author: darran.lofthouse(a)jboss.com
Date: 2007-08-13 13:18:45 -0400 (Mon, 13 Aug 2007)
New Revision: 4347
Modified:
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/BufferedStreamResult.java
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/BufferedStreamSource.java
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/DeserializerSupport.java
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/soap/XMLFragment.java
Log:
[ASPATCH-206] / [JBPAPP-257] JBossWS - Incorrect handling of charsets when the default
charset is not UTF-8.
Modified:
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/BufferedStreamResult.java
===================================================================
---
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/BufferedStreamResult.java 2007-08-13
17:06:55 UTC (rev 4346)
+++
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/BufferedStreamResult.java 2007-08-13
17:18:45 UTC (rev 4347)
@@ -28,6 +28,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
+import java.io.UnsupportedEncodingException;
import javax.xml.transform.stream.StreamResult;
@@ -51,7 +52,7 @@
{
try
{
- IOUtils.copyStream(getOutputStream(), new
ByteArrayInputStream(xmlFragment.getBytes()));
+ IOUtils.copyStream(getOutputStream(), new
ByteArrayInputStream(xmlFragment.getBytes("UTF-8")));
}
catch (IOException e)
{
@@ -64,7 +65,7 @@
{
return null;
}
-
+
@Override
public OutputStream getOutputStream()
{
@@ -82,9 +83,19 @@
{
throw new UnsupportedOperationException();
}
-
+
public String toString()
{
- return baos.toString();
+ String result = null;
+ try
+ {
+ result = baos.toString("UTF-8");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ WSException.rethrow(e);
+ }
+
+ return result;
}
}
Modified:
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/BufferedStreamSource.java
===================================================================
---
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/BufferedStreamSource.java 2007-08-13
17:06:55 UTC (rev 4346)
+++
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/BufferedStreamSource.java 2007-08-13
17:18:45 UTC (rev 4347)
@@ -30,6 +30,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
+import java.io.UnsupportedEncodingException;
import javax.xml.transform.stream.StreamSource;
@@ -112,7 +113,16 @@
{
String retStr = null;
if (bytes != null)
- retStr = new String(bytes);
+ {
+ try
+ {
+ retStr = new String(bytes, "UTF-8");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ WSException.rethrow(e);
+ }
+ }
else if (chars != null)
retStr = new String(chars);
return "" + retStr;
Modified:
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/DeserializerSupport.java
===================================================================
---
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/DeserializerSupport.java 2007-08-13
17:06:55 UTC (rev 4346)
+++
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/DeserializerSupport.java 2007-08-13
17:18:45 UTC (rev 4347)
@@ -24,6 +24,7 @@
// $Id$
import java.io.ByteArrayOutputStream;
+import java.io.UnsupportedEncodingException;
import javax.xml.namespace.QName;
import javax.xml.rpc.encoding.Deserializer;
@@ -97,7 +98,7 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
StreamResult streamResult = new StreamResult(baos);
tf.newTransformer().transform(source, streamResult);
- xmlFragment = new String(baos.toByteArray());
+ xmlFragment = new String(baos.toByteArray(),"UTF-8");
if (xmlFragment.startsWith("<?xml"))
{
int index = xmlFragment.indexOf(">");
@@ -109,6 +110,10 @@
{
WSException.rethrow(e);
}
+ catch (UnsupportedEncodingException e)
+ {
+ WSException.rethrow(e);
+ }
return xmlFragment;
}
Modified:
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/soap/XMLFragment.java
===================================================================
---
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/soap/XMLFragment.java 2007-08-13
17:06:55 UTC (rev 4346)
+++
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/soap/XMLFragment.java 2007-08-13
17:18:45 UTC (rev 4347)
@@ -177,7 +177,7 @@
Reader reader = streamSource.getReader();
{
if (reader == null)
- reader = new InputStreamReader(streamSource.getInputStream());
+ reader = new InputStreamReader(streamSource.getInputStream(),
"UTF-8");
}
char[] cbuf = new char[1024];