Author: jim.ma
Date: 2010-11-22 00:48:32 -0500 (Mon, 22 Nov 2010)
New Revision: 13311
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/request.xml
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/util/xml/BufferedStreamSource.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/XMLFragmentTestCase.java
Log:
[JBPAPP-5404]:JBossWS problem when using ws-security with Dispatch/Payload mode client
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/util/xml/BufferedStreamSource.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/util/xml/BufferedStreamSource.java 2010-11-19
16:45:10 UTC (rev 13310)
+++
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/util/xml/BufferedStreamSource.java 2010-11-22
05:48:32 UTC (rev 13311)
@@ -29,9 +29,11 @@
import java.io.InputStream;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
+import java.net.URL;
import javax.xml.transform.stream.StreamSource;
+import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
import org.jboss.wsf.common.IOUtils;
@@ -43,6 +45,7 @@
*/
public final class BufferedStreamSource extends StreamSource
{
+ private static final Logger log = Logger.getLogger(BufferedStreamSource.class);
private byte[] bytes;
private char[] chars;
@@ -71,6 +74,23 @@
}
chars = charArrayWriter.toCharArray();
}
+
+ //JBWS-3164:try to create InputStream from systemId
+ String systemId = source.getSystemId();
+ if (sourceInputStream == null && sourceReader == null &&
systemId != null)
+ {
+ try
+ {
+ URL url = new URL(systemId);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+ IOUtils.copyStream(baos, url.openStream());
+ bytes = baos.toByteArray();
+ }
+ catch (Exception e)
+ {
+ log.warn("Failed to create inputstream from systemId of
StreamSource");
+ }
+ }
}
catch (IOException ex)
{
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/XMLFragmentTestCase.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/XMLFragmentTestCase.java 2010-11-19
16:45:10 UTC (rev 13310)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/XMLFragmentTestCase.java 2010-11-22
05:48:32 UTC (rev 13311)
@@ -28,7 +28,10 @@
import org.w3c.dom.Element;
import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.PrintWriter;
/**
@@ -95,4 +98,15 @@
assertFalse("Should not contain processing instruction",
s.startsWith("<?xml"));
assertEquals(XML_STRING, s);
}
+
+ //JBWS-3164
+ public void testStreamSourceConstructedWithFile() throws Exception {
+ //File file = new
File(this.getClass().getResource("request.xml").toString()) will break this
test
+ File file = new
File(this.getClass().getResource("request.xml").getFile());
+ StreamSource requestSource = new StreamSource(file);
+ XMLFragment xmlFragment = new XMLFragment(requestSource);
+ java.io.ByteArrayOutputStream bout = new java.io.ByteArrayOutputStream();
+ xmlFragment.writeTo(bout);
+ assertTrue(new String(bout.toByteArray()).indexOf("Hello") > -1);
+ }
}
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/request.xml
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/request.xml
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/request.xml 2010-11-22
05:48:32 UTC (rev 13311)
@@ -0,0 +1,4 @@
+<?xml version = '1.0' encoding = 'UTF-8'?>
+<ns1:Request xmlns="http://ws.jboss.org"
xmlns:ns1="http://ws.jboss.org/jbws3164">
+ <ns1:Arg>Hello</ns1:Arg>
+</ns1:Request>
\ No newline at end of file