You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/07/23 23:33:48 UTC
svn commit: r797232 - in /cxf/trunk/distribution/src/main/release/samples:
aegis/src/demo/hw/client/ aegis/src/demo/hw/server/
mtom/src/demo/mtom/client/ mtom/src/demo/mtom/server/
Author: dkulp
Date: Thu Jul 23 21:33:48 2009
New Revision: 797232
URL: http://svn.apache.org/viewvc?rev=797232&view=rev
Log:
Fix issues in mtom demo of the streams getting corrupt
Fix checkstyle issues in aegis demo
Modified:
cxf/trunk/distribution/src/main/release/samples/aegis/src/demo/hw/client/Client.java
cxf/trunk/distribution/src/main/release/samples/aegis/src/demo/hw/server/HelloWorld.java
cxf/trunk/distribution/src/main/release/samples/aegis/src/demo/hw/server/HelloWorldImpl.java
cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/TestMtomPortTypeImpl.java
Modified: cxf/trunk/distribution/src/main/release/samples/aegis/src/demo/hw/client/Client.java
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/aegis/src/demo/hw/client/Client.java?rev=797232&r1=797231&r2=797232&view=diff
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/aegis/src/demo/hw/client/Client.java (original)
+++ cxf/trunk/distribution/src/main/release/samples/aegis/src/demo/hw/client/Client.java Thu Jul 23 21:33:48 2009
@@ -19,11 +19,13 @@
package demo.hw.client;
-import org.apache.cxf.aegis.databinding.AegisDatabinding;
-import org.apache.cxf.frontend.ClientProxyFactoryBean;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
+
+
import demo.hw.server.HelloWorld;
public final class Client {
Modified: cxf/trunk/distribution/src/main/release/samples/aegis/src/demo/hw/server/HelloWorld.java
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/aegis/src/demo/hw/server/HelloWorld.java?rev=797232&r1=797231&r2=797232&view=diff
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/aegis/src/demo/hw/server/HelloWorld.java (original)
+++ cxf/trunk/distribution/src/main/release/samples/aegis/src/demo/hw/server/HelloWorld.java Thu Jul 23 21:33:48 2009
@@ -23,6 +23,6 @@
public interface HelloWorld {
String sayHi(String text);
- public Document getADocument();
+ Document getADocument();
}
Modified: cxf/trunk/distribution/src/main/release/samples/aegis/src/demo/hw/server/HelloWorldImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/aegis/src/demo/hw/server/HelloWorldImpl.java?rev=797232&r1=797231&r2=797232&view=diff
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/aegis/src/demo/hw/server/HelloWorldImpl.java (original)
+++ cxf/trunk/distribution/src/main/release/samples/aegis/src/demo/hw/server/HelloWorldImpl.java Thu Jul 23 21:33:48 2009
@@ -33,18 +33,18 @@
}
public Document getADocument() {
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder db;
- try {
- db = dbf.newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- throw new RuntimeException(e);
- }
- Document doc = db.newDocument();
- Element carrot = doc.createElement("carrot");
- doc.appendChild(carrot);
- carrot.appendChild(doc.createTextNode("Carrots are roots"));
-
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db;
+ try {
+ db = dbf.newDocumentBuilder();
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ }
+ Document doc = db.newDocument();
+ Element carrot = doc.createElement("carrot");
+ doc.appendChild(carrot);
+ carrot.appendChild(doc.createTextNode("Carrots are roots"));
+
return doc;
}
}
Modified: cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java?rev=797232&r1=797231&r2=797232&view=diff
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java (original)
+++ cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java Thu Jul 23 21:33:48 2009
@@ -22,7 +22,6 @@
import java.awt.Image;
import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
@@ -50,9 +49,6 @@
}
public static void main(String args[]) throws Exception {
-
- Client client = new Client();
-
if (args.length == 0) {
System.out.println("Please specify the WSDL file.");
System.exit(1);
@@ -83,7 +79,10 @@
Holder<byte[]> param = new Holder<byte[]>();
param.value = new byte[(int) fileSize];
InputStream in = fileURL.openStream();
- in.read(param.value);
+ int len = in.read(param.value);
+ while (len < fileSize) {
+ len += in.read(param.value, len, (int)(fileSize - len));
+ }
System.out.println("--Sending the me.bmp image to server");
System.out.println("--Sending a name value of " + name.value);
@@ -123,8 +122,4 @@
System.exit(0);
}
- private static InputStream getResourceStream(File file) throws Exception {
- InputStream in = new FileInputStream(file);
- return in;
- }
}
Modified: cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/TestMtomPortTypeImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/TestMtomPortTypeImpl.java?rev=797232&r1=797231&r2=797232&view=diff
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/TestMtomPortTypeImpl.java (original)
+++ cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/TestMtomPortTypeImpl.java Thu Jul 23 21:33:48 2009
@@ -18,10 +18,14 @@
*/
package demo.mtom.server;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import javax.activation.DataHandler;
import javax.jws.WebService;
+import javax.mail.util.ByteArrayDataSource;
import javax.xml.ws.Holder;
import org.apache.cxf.mime.TestMtomPortType;
@@ -44,12 +48,29 @@
try {
System.out.println("Received image with mtom enabled from client");
InputStream mtomIn = attachinfo.value.getInputStream();
- long fileSize = 0;
- System.out.println("The image data size is " + mtomIn.available());
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ copy(mtomIn, out);
+ System.out.println("The image data size is " + out.size());
name.value = "Hello " + name.value;
mtomIn.close();
+ attachinfo.value = new DataHandler(new ByteArrayDataSource(out.toByteArray(),
+ attachinfo.value.getContentType()));
} catch (Exception e) {
e.printStackTrace();
}
}
+ public static int copy(final InputStream input, final OutputStream output) throws IOException {
+ final byte[] buffer = new byte[4096];
+ int n = 0;
+ n = input.read(buffer);
+ int total = 0;
+ while (-1 != n) {
+ output.write(buffer, 0, n);
+ total += n;
+ n = input.read(buffer);
+ }
+ return total;
+ }
+
+
}