cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gma...@apache.org
Subject svn commit: r589363 - in /incubator/cxf/trunk/distribution/src/main/release/samples/mtom: build.xml src/demo/mtom/client/Client.java
Date Sun, 28 Oct 2007 14:33:41 GMT
Author: gmazza
Date: Sun Oct 28 07:33:41 2007
New Revision: 589363

URL: http://svn.apache.org/viewvc?rev=589363&view=rev
Log:
Simplified method of handling me.bmp file.

Modified:
    incubator/cxf/trunk/distribution/src/main/release/samples/mtom/build.xml
    incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/mtom/build.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/mtom/build.xml?rev=589363&r1=589362&r2=589363&view=diff
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/mtom/build.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/mtom/build.xml Sun Oct 28 07:33:41
2007
@@ -22,7 +22,7 @@
     <import file="../common_build.xml"/>        
         
     <target name="client" description="run demo client" depends="build">
-        <copy toFile="${build.classes.dir}/demo/mtom/client/me.bmp" file="${basedir}/src/demo/mtom/client/me.bmp"/>
+        <copy toFile="${build.classes.dir}/me.bmp" file="${basedir}/src/demo/mtom/client/me.bmp"/>
         <property name="param" value=""/>
         <cxfrun classname="demo.mtom.client.Client"
             param1="${basedir}/wsdl/mtom_xop.wsdl" 
@@ -41,7 +41,7 @@
     </target>
     
     <target name="war" depends="build">
-        <copy toFile="${build.classes.dir}/demo/mtom/client/me.bmp" file="${basedir}/src/demo/mtom/client/me.bmp"/>
+        <copy toFile="${build.classes.dir}/me.bmp" file="${basedir}/src/demo/mtom/client/me.bmp"/>
         <cxfwar wsdl="*.*" filename="mtom.war"/>
 	</target>
     <property name="cxf.war.file.name" value="mtom"/>

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java?rev=589363&r1=589362&r2=589363&view=diff
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
(original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
Sun Oct 28 07:33:41 2007
@@ -24,11 +24,11 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
+import java.net.URI;
 import java.net.URL;
 
 import javax.activation.DataHandler;
 import javax.imageio.ImageIO;
-import javax.mail.util.ByteArrayDataSource;
 import javax.xml.namespace.QName;
 import javax.xml.ws.Binding;
 import javax.xml.ws.BindingProvider;
@@ -40,9 +40,11 @@
 
 public final class Client {
 
-    private static final QName SERVICE_NAME = new QName("http://cxf.apache.org/mime", "TestMtomService");
+    private static final QName SERVICE_NAME = new QName("http://cxf.apache.org/mime", 
+        "TestMtomService");
 
-    private static final QName PORT_NAME = new QName("http://cxf.apache.org/mime", "TestMtomPort");
+    private static final QName PORT_NAME = new QName("http://cxf.apache.org/mime", 
+        "TestMtomPort");
 
     private Client() {
     }
@@ -71,19 +73,16 @@
         Binding binding = ((BindingProvider)port).getBinding();
         ((SOAPBinding)binding).setMTOMEnabled(true);
 
-        InputStream pre = client.getClass().getResourceAsStream("me.bmp");
-        long fileSize = 0;
-        for (int i = pre.read(); i != -1; i = pre.read()) {
-            fileSize++;
-        }
+        URL fileURL = client.getClass().getClassLoader().getResource("me.bmp");
+        File aFile = new File(new URI(fileURL.toString()));
+        long fileSize = aFile.length();
         System.out.println("Filesize of me.bmp image is: " + fileSize);
 
-        Holder<byte[]> param = new Holder<byte[]>();
-        param.value = new byte[(int) fileSize];
         System.out.println("\nStarting MTOM Test using basic byte array:");
-
         Holder<String> name = new Holder<String>("Sam");
-        InputStream in = client.getClass().getResourceAsStream("me.bmp");
+        Holder<byte[]> param = new Holder<byte[]>();
+        param.value = new byte[(int) fileSize];
+        InputStream in = fileURL.openStream();
         in.read(param.value);
         System.out.println("--Sending the me.bmp image to server");
         System.out.println("--Sending a name value of " + name.value);
@@ -102,10 +101,9 @@
         System.out.println("\nStarting MTOM test with DataHandler:");        
         name.value = "Bob";
         Holder<DataHandler> handler = new Holder<DataHandler>();
-        byte[] data = new byte[(int) fileSize];
-        client.getClass().getResourceAsStream("me.bmp").read(data);
-        handler.value = new DataHandler(new ByteArrayDataSource(data, 
-            "application/octet-stream"));
+
+        handler.value = new DataHandler(fileURL);
+
         System.out.println("--Sending the me.bmp image to server");
         System.out.println("--Sending a name value of " + name.value);
 



Mime
View raw message