Author: thomas.diesler(a)jboss.com
Date: 2007-03-28 15:01:26 -0400 (Wed, 28 Mar 2007)
New Revision: 2706
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAPFaultHelperJAXRPC.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArraySerializer.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/SOAPFaultHelperJAXWS.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientProxy.java
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/ObjectContent.java
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPContentElement.java
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/XMLContent.java
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/XMLFragment.java
trunk/jbossws-core/src/java/org/jboss/ws/core/utils/DOMUtils.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/common/jbossxb/SerializerDeserializerTestCase.java
Log:
Fix stream source exaustion
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAPFaultHelperJAXRPC.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAPFaultHelperJAXRPC.java 2007-03-28
17:18:54 UTC (rev 2705)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAPFaultHelperJAXRPC.java 2007-03-28
19:01:26 UTC (rev 2706)
@@ -269,7 +269,7 @@
XMLFragment xmlFragment = new XMLFragment(result);
SOAPFactoryImpl soapFactory = new SOAPFactoryImpl();
- Element domElement = DOMUtils.parse(xmlFragment.toStringFragment());
+ Element domElement = DOMUtils.parse(xmlFragment.resultToString());
SOAPElement soapElement = soapFactory.createElement(domElement);
detail = soapFault.addDetail();
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java 2007-03-28
17:18:54 UTC (rev 2705)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java 2007-03-28
19:01:26 UTC (rev 2706)
@@ -58,11 +58,11 @@
{
log.debug("deserialize: [xmlName=" + xmlName + ",xmlType=" +
xmlType + "]");
- Element soapElement = DOMUtils.sourceToElement(source);
try
{
ParameterMetaData paramMetaData =
(ParameterMetaData)serContext.getProperty(ParameterMetaData.class.getName());
+ Element soapElement = DOMUtils.sourceToElement(source);
QName compXmlType = getComponentTypeFromAttribute(soapElement);
paramMetaData.setSOAPArrayCompType(compXmlType);
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArraySerializer.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArraySerializer.java 2007-03-28
17:18:54 UTC (rev 2705)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArraySerializer.java 2007-03-28
19:01:26 UTC (rev 2706)
@@ -185,7 +185,7 @@
Result result = ser.serialize(new QName("item"), xmlType,
compValue, serContext, null);
XMLFragment fragment = new XMLFragment(result);
- buffer.append(fragment.toStringFragment());
+ buffer.append(fragment.resultToString());
}
}
}
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/SOAPFaultHelperJAXWS.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/SOAPFaultHelperJAXWS.java 2007-03-28
17:18:54 UTC (rev 2705)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/SOAPFaultHelperJAXWS.java 2007-03-28
19:01:26 UTC (rev 2706)
@@ -320,7 +320,7 @@
XMLFragment fragment = new XMLFragment(result);
SOAPFactoryImpl soapFactory = new SOAPFactoryImpl();
- Element domElement = DOMUtils.parse(fragment.toStringFragment());
+ Element domElement = DOMUtils.parse(fragment.resultToString());
return soapFactory.createElement(domElement);
}
catch (BindingException e)
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2007-03-28
17:18:54 UTC (rev 2705)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2007-03-28
19:01:26 UTC (rev 2706)
@@ -23,7 +23,6 @@
// $Id$
-import java.net.HttpURLConnection;
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.HashSet;
@@ -37,7 +36,6 @@
import javax.xml.ws.Binding;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.EndpointReference;
-import javax.xml.ws.ProtocolException;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.handler.Handler;
import javax.xml.ws.handler.HandlerResolver;
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientProxy.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientProxy.java 2007-03-28
17:18:54 UTC (rev 2705)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientProxy.java 2007-03-28
19:01:26 UTC (rev 2706)
@@ -202,22 +202,29 @@
*/
private void handleException(Exception ex) throws Throwable
{
- Throwable th = ex;
if (ex instanceof SOAPFaultException)
{
// Unwrap the cause if it is an Application Exception, otherwise use a protocol
exception
Throwable cause = ex.getCause();
if (cause instanceof Exception)
{
+ // Throw unwrapped WebServiceException
if (cause instanceof WebServiceException)
- th = cause;
- else if (cause instanceof SOAPException)
- th = ex;
- else if (cause instanceof RuntimeException)
- th = ex;
+ throw (WebServiceException)cause;
+
+ // Throw wrapped SOAPException
+ if (cause instanceof SOAPException)
+ throw (SOAPFaultException)ex;
+
+ // Throw wrapped RuntimeException
+ if (cause instanceof RuntimeException)
+ throw (SOAPFaultException)ex;
+
+ // Throw all other causes
+ throw (Exception)cause;
}
}
- throw th;
+ throw ex;
}
class AsyncRunnable implements Runnable
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/soap/ObjectContent.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/soap/ObjectContent.java 2007-03-28
17:18:54 UTC (rev 2705)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/soap/ObjectContent.java 2007-03-28
19:01:26 UTC (rev 2706)
@@ -37,7 +37,6 @@
import org.jboss.ws.core.jaxrpc.binding.SerializerFactoryBase;
import org.jboss.ws.core.jaxrpc.binding.SerializerSupport;
import org.jboss.ws.core.utils.JavaUtils;
-import org.jboss.ws.metadata.umdm.ParameterMetaData;
/**
* Represents the OBJECT_VALID state of an {@link SOAPContentElement}.<br>
@@ -46,37 +45,40 @@
* @version $Id$
* @since 05.02.2007
*/
-public class ObjectContent extends SOAPContent {
+public class ObjectContent extends SOAPContent
+{
private static Logger log = Logger.getLogger(ObjectContent.class);
// The java object content of this element.
private Object objectValue;
- protected ObjectContent(SOAPContentElement container) {
+ protected ObjectContent(SOAPContentElement container)
+ {
super(container);
}
- State getState() {
+ State getState()
+ {
return State.OBJECT_VALID;
}
- SOAPContent transitionTo(State nextState) {
-
+ SOAPContent transitionTo(State nextState)
+ {
SOAPContent next = null;
- if(State.XML_VALID == nextState)
+ if (State.XML_VALID == nextState)
{
XMLFragment fragment = marshallObjectContents();
XMLContent xmlValid = new XMLContent(container);
xmlValid.setXMLFragment(fragment);
next = xmlValid;
}
- else if(State.OBJECT_VALID == nextState)
+ else if (State.OBJECT_VALID == nextState)
{
next = this;
}
- else if(State.DOM_VALID == nextState)
+ else if (State.DOM_VALID == nextState)
{
// first transition to XML valid
XMLFragment fragment = marshallObjectContents();
@@ -94,28 +96,34 @@
return next;
}
- public Source getPayload() {
+ public Source getPayload()
+ {
throw new IllegalStateException("Payload not available");
}
- public void setPayload(Source source) {
- throw new IllegalStateException("Payload not available");
+ public void setPayload(Source source)
+ {
+ throw new IllegalStateException("Payload cannot be set on object
content");
}
- public XMLFragment getXMLFragment() {
+ public XMLFragment getXMLFragment()
+ {
throw new IllegalStateException("XMLFragment not available");
}
- public void setXMLFragment(XMLFragment xmlFragment) {
+ public void setXMLFragment(XMLFragment xmlFragment)
+ {
throw new IllegalStateException("XMLFragment not available");
}
- public Object getObjectValue() {
+ public Object getObjectValue()
+ {
return objectValue;
}
- public void setObjectValue(Object objValue) {
+ public void setObjectValue(Object objValue)
+ {
this.objectValue = objValue;
}
@@ -149,7 +157,7 @@
}
Result result = ser.serialize(container, serContext);
-
+
xmlFragment = new XMLFragment(result);
log.debug("xmlFragment: " + xmlFragment);
}
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPContentElement.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPContentElement.java 2007-03-28
17:18:54 UTC (rev 2705)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPContentElement.java 2007-03-28
19:01:26 UTC (rev 2706)
@@ -37,6 +37,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.core.jaxws.handler.MessageContextJAXWS;
+import org.jboss.ws.core.soap.SOAPContent.State;
import org.jboss.ws.core.utils.DOMWriter;
import org.jboss.ws.extensions.xop.XOPContext;
import org.jboss.ws.metadata.umdm.ParameterMetaData;
@@ -67,7 +68,6 @@
* @author Thomas.Diesler(a)jboss.org
* @author Heiko.Braun(a)jboss.org
* @since 13-Dec-2004
- *
*/
public class SOAPContentElement extends SOAPElementImpl implements SOAPContentAccess
{
@@ -126,7 +126,7 @@
return getParamMetaData().getJavaType();
}
- private void transitionTo(SOAPContent.State nextState)
+ private void transitionTo(State nextState)
{
if (nextState != soapContent.getState())
{
@@ -145,8 +145,9 @@
*/
public Source getPayload()
{
- // expand to DOM, so the source is repeatedly readable
- transitionTo(SOAPContent.State.DOM_VALID);
+ if (soapContent.getState() == State.OBJECT_VALID)
+ transitionTo(State.DOM_VALID);
+
return soapContent.getPayload();
}
@@ -160,7 +161,7 @@
public XMLFragment getXMLFragment()
{
- transitionTo(SOAPContent.State.XML_VALID);
+ transitionTo(State.XML_VALID);
return soapContent.getXMLFragment();
}
@@ -172,7 +173,7 @@
public Object getObjectValue()
{
- transitionTo(SOAPContent.State.OBJECT_VALID);
+ transitionTo(State.OBJECT_VALID);
return soapContent.getObjectValue();
}
@@ -507,7 +508,7 @@
private void expandToDOM()
{
if (!lockDOMExpansion)
- transitionTo(SOAPContent.State.DOM_VALID);
+ transitionTo(State.DOM_VALID);
}
public void setValue(String value)
@@ -542,7 +543,7 @@
}
else
{
- transitionTo(SOAPContent.State.XML_VALID);
+ transitionTo(State.XML_VALID);
soapContent.getXMLFragment().writeTo(writer);
}
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/soap/XMLContent.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/soap/XMLContent.java 2007-03-28 17:18:54
UTC (rev 2705)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/soap/XMLContent.java 2007-03-28 19:01:26
UTC (rev 2706)
@@ -85,7 +85,6 @@
SOAPContent transitionTo(State nextState)
{
-
SOAPContent next;
if (State.XML_VALID == nextState)
@@ -108,7 +107,7 @@
{
throw new IllegalArgumentException("Illegal state requested: " +
nextState);
}
-
+
return next;
}
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/soap/XMLFragment.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/soap/XMLFragment.java 2007-03-28
17:18:54 UTC (rev 2705)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/soap/XMLFragment.java 2007-03-28
19:01:26 UTC (rev 2706)
@@ -21,14 +21,15 @@
*/
package org.jboss.ws.core.soap;
-//$Id: $
+// $Id: $
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
+import java.io.Reader;
import java.io.Writer;
import javax.xml.transform.Result;
@@ -37,6 +38,7 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
+import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
import org.jboss.ws.core.jaxrpc.binding.BufferedStreamResult;
import org.jboss.ws.core.utils.DOMUtils;
@@ -52,15 +54,29 @@
* @see XMLContent
*
* @author Heiko.Braun(a)jboss.org
- * @since 05.02.2007
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 05-Feb-2007
*/
public class XMLFragment
{
+ // provide logging
+ private static Logger log = Logger.getLogger(XMLFragment.class);
+
private Source source;
private Result result;
- private boolean idempotent = true;
+ // An exception that is created when a client
+ // accesses a StreamSource that can only be read once
+ private RuntimeException streamSourceAccessMarker;
+ /** Factory method to create XMLFragment from strings.
+ */
+ public static XMLFragment fromStringFragment(String fragment)
+ {
+ Source source = new StreamSource(new ByteArrayInputStream(fragment.getBytes()));
+ return new XMLFragment(source);
+ }
+
public XMLFragment(Source source)
{
this.source = source;
@@ -75,55 +91,46 @@
{
if (null == source)
throw new IllegalStateException("Source not available");
+
+ source = beginStreamSourceAccess(source);
+ endStreamSourceAccess();
+
return source;
}
- public Result getResult()
+ public String resultToString()
{
- if (null == source)
- throw new IllegalStateException("Result not available");
- return result;
- }
+ if (source != null)
+ throw new IllegalStateException("Source should never be converted to
String");
- public String toStringFragment()
- {
- if (!idempotent)
- throw new IllegalStateException("Trying to call a non-idempotent
operation");
-
- if (this.source != null)
- return sourceToStringFragement(this.source);
- else return resultToStringFragment(this.result);
+ return resultToString(this.result);
}
/**
- * Note this method <b>is not expected to be idempotent</b>.
- * It depends on the underlying source impl. that backs the implementation.
+ * Transform the Source or Result to an Element
*/
public Element toElement()
{
- if (!idempotent)
- throw new IllegalStateException("Trying to call a non-idempotent
operation");
-
Element resultingElement = null;
try
{
if (source != null)
{
- resultingElement = DOMUtils.sourceToElement(source);
-
- // Any Source besides DOMSource is expected not to be idempotent
- if (!(source instanceof DOMSource))
- idempotent = false;
-
+ try
+ {
+ source = beginStreamSourceAccess(source);
+ resultingElement = DOMUtils.sourceToElement(source);
+ endStreamSourceAccess();
+ }
+ catch (IOException ex)
+ {
+ handleStreamSourceAccessException(ex);
+ }
}
else
{
- resultingElement = DOMUtils.parse(resultToStringFragment(result));
-
- // Any Result besides DOMResult is expected not to be idempotent
- if (!(result instanceof DOMResult))
- idempotent = false;
+ resultingElement = DOMUtils.parse(resultToString(result));
}
}
catch (IOException e)
@@ -134,39 +141,6 @@
return resultingElement;
}
- /**
- * Factory method to create XMLFragment from strings.
- * @param fragment
- * @return new XMLFragment
- */
- public static XMLFragment fromStringFragment(String fragment)
- {
- Source source = new StreamSource(new ByteArrayInputStream(fragment.getBytes()));
- return new XMLFragment(source);
- }
-
- private String resultToStringFragment(Result result)
- {
-
- if (result instanceof DOMResult)
- {
- return DOMWriter.printNode(((DOMResult)result).getNode(), false);
- }
- else if (result instanceof BufferedStreamResult)
- {
- BufferedStreamResult br = (BufferedStreamResult)result;
- byte[] bytes = ((ByteArrayOutputStream)br.getOutputStream()).toByteArray();
- return new String(bytes);
- }
-
- throw new IllegalArgumentException("Unable to process
javax.xml.transform.Result implementation: " + result);
- }
-
- private static String sourceToStringFragement(Source source)
- {
- throw new IllegalArgumentException("Source should never be converted to
String");
- }
-
public void writeTo(Writer writer) throws IOException
{
if (result != null)
@@ -179,6 +153,11 @@
}
}
+ public void writeTo(OutputStream out) throws IOException
+ {
+ writeTo(new PrintWriter(out));
+ }
+
/**
* Should only be called with <code>jbossws.SOAPMessage==TRACE</code>
*/
@@ -187,31 +166,42 @@
if (source instanceof DOMSource)
{
DOMSource domSource = (DOMSource)source;
- DOMWriter dw = new DOMWriter(writer).setPrettyprint(false);
- dw.print(domSource.getNode());
+ DOMWriter domWriter = new DOMWriter(writer).setPrettyprint(false);
+ domWriter.print(domSource.getNode());
}
else if (source instanceof StreamSource)
{
- StreamSource streamSource = (StreamSource)source;
- copyStream(streamSource.getInputStream(), writer);
+ try
+ {
+ source = beginStreamSourceAccess(source);
+
+ StreamSource streamSource = (StreamSource)source;
+
+ Reader reader = streamSource.getReader();
+ if (reader == null)
+ reader = new InputStreamReader(streamSource.getInputStream());
+
+ char[] cbuf = new char[1024];
+ int r = reader.read(cbuf);
+ while (r > 0)
+ {
+ writer.write(cbuf, 0, r);
+ r = reader.read(cbuf);
+ }
+
+ endStreamSourceAccess();
+ }
+ catch (IOException ex)
+ {
+ handleStreamSourceAccessException(ex);
+ }
}
else
{
- throw new IllegalArgumentException("Unable to process
javax.xml.transform.Source implementation :" + result);
+ throw new IllegalArgumentException("Unable to process source: " +
source);
}
}
- private static void copyStream(InputStream ins, Writer writer) throws IOException
- {
- byte[] bytes = new byte[1024];
- int r = ins.read(bytes);
- while (r > 0)
- {
- writer.write(new String(bytes), 0, r);
- r = ins.read(bytes);
- }
- }
-
private void writeResult(Writer writer)
{
if (result instanceof DOMResult)
@@ -236,18 +226,65 @@
}
else
{
- throw new IllegalArgumentException("Unable to process
javax.xml.transform.Result implementation: " + result);
+ throw new IllegalArgumentException("Unable to process result: " +
result);
}
}
- public void writeTo(OutputStream out) throws IOException
+ private String resultToString(Result result)
{
- writeTo(new PrintWriter(out));
+ if (result instanceof DOMResult)
+ {
+ return DOMWriter.printNode(((DOMResult)result).getNode(), false);
+ }
+ else if (result instanceof BufferedStreamResult)
+ {
+ BufferedStreamResult br = (BufferedStreamResult)result;
+ byte[] bytes = ((ByteArrayOutputStream)br.getOutputStream()).toByteArray();
+ return new String(bytes);
+ }
+
+ throw new IllegalArgumentException("Unable to process
javax.xml.transform.Result implementation: " + result);
}
+ private Source beginStreamSourceAccess(Source source)
+ {
+ if (source instanceof StreamSource)
+ {
+ // Do some brute force buffering
+ try
+ {
+ Element element = DOMUtils.sourceToElement(source);
+ source = new DOMSource(element);
+ }
+ catch (IOException ex)
+ {
+ throw new WSException("Cannot create DOMSource", ex);
+ }
+ }
+ return source;
+ }
+
+ private void endStreamSourceAccess()
+ {
+ // Create the marker exception
+ if (source instanceof StreamSource)
+ {
+ streamSourceAccessMarker = new RuntimeException();
+ }
+ }
+
+ private void handleStreamSourceAccessException(IOException ex) throws IOException
+ {
+ if (source instanceof StreamSource && streamSourceAccessMarker != null)
+ {
+ log.error("StreamSource was previously accessed from",
streamSourceAccessMarker);
+ }
+ throw ex;
+ }
+
public String toString()
{
String contents = source != null ? "source=" + source :
"result=" + result;
- return "XMLFragment {" + contents + ", idempotent=" +
idempotent + "}";
+ return "XMLFragment {" + contents + "}";
}
}
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/utils/DOMUtils.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/utils/DOMUtils.java 2007-03-28 17:18:54
UTC (rev 2705)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/utils/DOMUtils.java 2007-03-28 19:01:26
UTC (rev 2706)
@@ -38,6 +38,7 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
@@ -69,7 +70,8 @@
// All elements created by the same thread are created by the same builder and belong
to the same doc
private static ThreadLocal documentThreadLocal = new ThreadLocal();
private static ThreadLocal builderThreadLocal = new ThreadLocal() {
- protected Object initialValue() {
+ protected Object initialValue()
+ {
try
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@@ -522,11 +524,12 @@
return doc;
}
- public static Element sourceToElement(Source source)
+ public static Element sourceToElement(Source source) throws IOException
{
Element elementResult = null;
- try {
+ try
+ {
if (source instanceof StreamSource)
{
StreamSource streamSource = (StreamSource)source;
@@ -541,10 +544,6 @@
Reader reader = streamSource.getReader();
elementResult = DOMUtils.parse(new InputSource(reader));
}
-
- // reset the excausted input stream
- String xmlStr = DOMWriter.printNode(elementResult, false);
- source = new StreamSource(new ByteArrayInputStream(xmlStr.getBytes()));
}
else if (source instanceof DOMSource)
{
@@ -581,9 +580,11 @@
}
}
- catch (Exception e)
+ catch (TransformerException ex)
{
- WSException.rethrow(e);
+ IOException ioex = new IOException();
+ ioex.initCause(ex);
+ throw ioex;
}
return elementResult;
Modified:
trunk/jbossws-tests/src/java/org/jboss/test/ws/common/jbossxb/SerializerDeserializerTestCase.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/common/jbossxb/SerializerDeserializerTestCase.java 2007-03-28
17:18:54 UTC (rev 2705)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/common/jbossxb/SerializerDeserializerTestCase.java 2007-03-28
19:01:26 UTC (rev 2706)
@@ -83,7 +83,7 @@
DeserializerFactoryBase deserializerFactory =
(DeserializerFactoryBase)typeMapping.getDeserializer(String.class, xmlType);
DeserializerSupport des =
(DeserializerSupport)deserializerFactory.getDeserializer();
- Source source = new StreamSource(new ByteArrayInputStream( new
XMLFragment(result).toStringFragment().getBytes()));
+ Source source = new StreamSource(new ByteArrayInputStream( new
XMLFragment(result).resultToString().getBytes()));
String out = (String)des.deserialize(xmlName, xmlType, source, serContext);
assertEquals(value, out);
@@ -101,7 +101,7 @@
DeserializerFactoryBase deserializerFactory =
(DeserializerFactoryBase)typeMapping.getDeserializer(Calendar.class, xmlType);
DeserializerSupport des =
(DeserializerSupport)deserializerFactory.getDeserializer();
- Source source = new StreamSource(new ByteArrayInputStream( new
XMLFragment(result).toStringFragment().getBytes()));
+ Source source = new StreamSource(new ByteArrayInputStream( new
XMLFragment(result).resultToString().getBytes()));
Calendar out = (Calendar)des.deserialize(xmlName, xmlType, source, serContext);
assertEquals(value.getTime(), out.getTime());
@@ -120,7 +120,7 @@
DeserializerFactoryBase deserializerFactory =
(DeserializerFactoryBase)typeMapping.getDeserializer(BigInteger.class, xmlType);
DeserializerSupport des =
(DeserializerSupport)deserializerFactory.getDeserializer();
- Source source = new StreamSource(new ByteArrayInputStream( new
XMLFragment(result).toStringFragment().getBytes()));
+ Source source = new StreamSource(new ByteArrayInputStream( new
XMLFragment(result).resultToString().getBytes()));
BigInteger out = (BigInteger)des.deserialize(xmlName, xmlType, source,
serContext);
assertEquals(value, out);
@@ -138,7 +138,7 @@
DeserializerFactoryBase deserializerFactory =
(DeserializerFactoryBase)typeMapping.getDeserializer(BigDecimal.class, xmlType);
DeserializerSupport des =
(DeserializerSupport)deserializerFactory.getDeserializer();
- Source source = new StreamSource(new ByteArrayInputStream( new
XMLFragment(result).toStringFragment().getBytes()));
+ Source source = new StreamSource(new ByteArrayInputStream( new
XMLFragment(result).resultToString().getBytes()));
BigDecimal out = (BigDecimal)des.deserialize(xmlName, xmlType, source,
serContext);
assertEquals(value, out);
@@ -161,7 +161,7 @@
DeserializerFactoryBase deserializerFactory =
(DeserializerFactoryBase)typeMapping.getDeserializer(QName.class, xmlType);
DeserializerSupport des =
(DeserializerSupport)deserializerFactory.getDeserializer();
- Source source = new StreamSource(new ByteArrayInputStream( new
XMLFragment(result).toStringFragment().getBytes()));
+ Source source = new StreamSource(new ByteArrayInputStream( new
XMLFragment(result).resultToString().getBytes()));
QName out = (QName)des.deserialize(xmlName, xmlType, source, serContext);
assertEquals(value, out);
@@ -179,7 +179,7 @@
DeserializerFactoryBase deserializerFactory =
(DeserializerFactoryBase)typeMapping.getDeserializer(URI.class, xmlType);
DeserializerSupport des =
(DeserializerSupport)deserializerFactory.getDeserializer();
- Source source = new StreamSource(new ByteArrayInputStream( new
XMLFragment(result).toStringFragment().getBytes()));
+ Source source = new StreamSource(new ByteArrayInputStream( new
XMLFragment(result).resultToString().getBytes()));
URI out = (URI)des.deserialize(xmlName, xmlType, source, serContext);
assertEquals(value, out);
@@ -197,7 +197,7 @@
DeserializerFactoryBase deserializerFactory =
(DeserializerFactoryBase)typeMapping.getDeserializer(byte[].class, xmlType);
DeserializerSupport des =
(DeserializerSupport)deserializerFactory.getDeserializer();
- Source source = new StreamSource(new ByteArrayInputStream( new
XMLFragment(result).toStringFragment().getBytes()));
+ Source source = new StreamSource(new ByteArrayInputStream( new
XMLFragment(result).resultToString().getBytes()));
byte[] out = (byte[])des.deserialize(xmlName, xmlType, source, serContext);
assertEquals(new String(value), new String(out));
@@ -215,7 +215,7 @@
DeserializerFactoryBase deserializerFactory =
(DeserializerFactoryBase)typeMapping.getDeserializer(byte[].class, xmlType);
DeserializerSupport des =
(DeserializerSupport)deserializerFactory.getDeserializer();
- Source source = new StreamSource(new ByteArrayInputStream( new
XMLFragment(result).toStringFragment().getBytes()));
+ Source source = new StreamSource(new ByteArrayInputStream( new
XMLFragment(result).resultToString().getBytes()));
byte[] out = (byte[])des.deserialize(xmlName, xmlType, source, serContext);
assertEquals(new String(value), new String(out));